public override void LoadFromXml(XmlNode connectionXml) { if (connectionXml.Name != "Connection") { throw new ArgumentException(string.Format("The Xml does not contain the correct type ({0}).", "Connection")); } ConnectionString = connectionXml.Attributes != null ? connectionXml.Attributes["connection"].Value : null; _connectionType = connectionXml.Attributes != null?ConvertConnectionTypeString(connectionXml.Attributes["connectionType"].Value) : ConnectionTypeEnum.ConnectionString; ReferenceName = connectionXml.Attributes != null ? connectionXml.Attributes["name"].Value : null; InvariantType = connectionXml.Attributes != null && connectionXml.Attributes["invariantType"] != null ? connectionXml.Attributes["invariantType"].Value : null; }
public void CreatePorts(ConnectionTypeEnum type, int count, bool extended = false) { Grid.SetSize(extended? GatePortView.ExtendedGatePortSize.Width : GatePortView.GatePortSize.Width, GateBodyView.LogicGateSize.Height); Grid.InitRows(count); for (int i = 0; i < count; i++) { GatePortView port = new(type, i, extended); port.Tapped += (p) => Tapped(p); port.ValueChanged += (newValue) => ValuesChanged?.Invoke(); Add(port); } }
public Device( string name, string description, string ip, string manufacturer, ConnectionTypeEnum primaryConnection, ConnectionTypeEnum secondaryConnection, string groupCreator, string pluginName, PluginTypeEnum?pluginType) : base(name, description) { Ip = new IpAddress(ip); Company = new Company(manufacturer); PrimaryConnection = primaryConnection; SecondaryConnection = secondaryConnection; CreatedBy = groupCreator; PluginName = pluginName; PluginType = pluginType ?? PluginTypeEnum.None; }
private void DrawConnection(Graphics graphics, Pen pen1, Pen pen2, PointF q1, PointF q2, ConnectionTypeEnum connection) { switch (connection) { case ConnectionTypeEnum.Line: graphics.DrawLine(pen1, q1, q2); break; case ConnectionTypeEnum.StepLeft: graphics.DrawLine(pen2, q1.X, q1.Y, q1.X, q2.Y); graphics.DrawLine(pen2, q1.X, q2.Y, q2.X, q2.Y); break; case ConnectionTypeEnum.StepRight: graphics.DrawLine(pen2, q1.X, q1.Y, q2.X, q1.Y); graphics.DrawLine(pen2, q2.X, q1.Y, q2.X, q2.Y); break; default: break; } }
/// <summary> /// Connect to an EZ-B. /// 1) Hostname can be a communication PORT. Get the port name from GetAvailableCommunicationPorts() /// 2) Hostname can be an IP Address, example: 192.168.1.5:6666 /// 3) Leave TCPPassword blank if connecting to an EZ-B. It is only used when connecting to another EZ-Builder instance /// 4) Baudrate is not used for TCP connections /// </summary> public async Task Connect(string hostname) { if (_isConnected) { throw new Exception("Already connected."); } //else //throw new Exception("NOT"); Log(false, "Attempting connection on {0}", hostname); if (hostname == string.Empty) { throw new Exception("No connection method specified"); } _connectionType = ConnectionTypeEnum.TCP; string[] parts = hostname.Split(':'); string ipAddress = parts[0]; int port = 23; if (parts.Length > 1) { port = Convert.ToInt16(parts[1]); } await _tcpClient.Connect(ipAddress, port, 3000); ConnectedEndPointAddress = ipAddress; _isConnected = true; if (!await PingController()) { throw new Exception("Controller Not Responding"); } Log(false, "Connected to {0}", hostname); Log(false, "EZ-B reports " + GetFirmwareVersion()); if (_firmwareResponse == 4) { EZBType = EZ_B_Type_Enum.ezb4; Log(false, "Welcome to EZ-B v4 Beta!"); _uniqueID = await sendCommand(12, CommandEnum.CmdGetUniqueID); Log(false, "EZ-B v4 ID: {0}", GetUniqueIDString()); Servo.SERVO_MAX = 180; Servo.SERVO_CENTER = 90; } else { throw new Exception("This device is not an EZ-B. Please follow the online tutorials on the EZ-Robot website."); } Servo.Init(); Digital.Init(); if (OnConnectionChange != null) { OnConnectionChange(_isConnected); } Log(false, "Connected"); }
public ConnectionRef(string referenceName, string connectionString, ConnectionTypeEnum connectionType, string invariantType) : this(referenceName, connectionString, connectionType) { InvariantType = invariantType; }
public ConnectionRef(string referenceName, string connectionString, ConnectionTypeEnum connectionType) { ReferenceName = referenceName; ConnectionString = connectionString; ConnectionType = connectionType; }