private PlcViewModel MapFromStorage(PlcConfiguration plc) { var res = _plcViewModelFactory.Invoke(plc.Plc, plc.Name); res.Root = MapFromStorage(res, plc.Root); return(res); }
public async System.Threading.Tasks.Task<bool> ConnectAsync(PlcConfiguration device) { port = new System.IO.Ports.SerialPort(device.Port); //TOOD: Configure the port based on settings port = new System.IO.Ports.SerialPort(device.Port, Convert.ToInt32(device.Options["BaudRate"]), (Parity)Enum.Parse(typeof(Parity), device.Options["Parity"]), Convert.ToInt32(device.Options["DataBits"]), (StopBits)Enum.Parse(typeof(StopBits), device.Options["StopBits"])); port.Open(); return true; }
/// <summary> /// Connects to a PLC /// </summary> /// <param name="device">The device configuration</param> /// <returns></returns> public async Task<bool> ConnectAsync(PlcConfiguration device) { client = new TcpClient(); await client.ConnectAsync(device.Address, Convert.ToInt32(device.Port)); if (client.Connected) { this.stream = client.GetStream(); } return client.Connected; }
private async void Form1_Load(object sender, EventArgs e) { PlcConfiguration configuration; configuration = new PlcConfiguration() { Address = "10.146.80.92", Port = "9600", Serial = false, DestinationNode = 1, SourceNode = 2, PreferTcpIp = false }; provider = new Omron.Transport.Win32FinsDriver(configuration); this.connectedLabel.Text = provider.Connected.ToString(); }