private void Connect(CpuInfo cpuInfo)
        {
            var cpu = new Cpu(_service, cpuInfo.Name);

            cpu.Connection.DeviceType                 = DeviceType.TcpIp;
            cpu.Connection.TcpIp.SourceStation        = ConfigurationProvider.SourceStationId;
            cpu.Connection.TcpIp.DestinationIpAddress = cpuInfo.IpAddress;

            cpu.Connected    += Cpu_Connected;
            cpu.Error        += Cpu_Error;
            cpu.Disconnected += Cpu_Disconnected;

            cpu.Connect();
        }
Exemplo n.º 2
0
        private void Service_Connected(object sender, PviEventArgs e)
        {
            log.Info($"Service_Connected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}");

            cpu = new Cpu(service, "cpu");
            cpu.Connection.DeviceType = DeviceType.TcpIp;
            cpu.Connection.TcpIp.DestinationIpAddress = Properties.Settings.Default.PVILocalIP;
            cpu.Connection.TcpIp.DestinationPort      = Convert.ToInt16(Properties.Settings.Default.PVILocalPort);
            cpu.Connection.TcpIp.DestinationStation   = Convert.ToByte(Properties.Settings.Default.PVIDestStation);
            cpu.Connection.TcpIp.SourceStation        = Convert.ToByte(Properties.Settings.Default.PVISrcStation);

            cpu.Connected    += cpu_Connected;
            cpu.Disconnected += cpu_Disconnected;
            cpu.Error        += cpu_Error;

            cpu.Connect();

            toolStripStatusLabel1.Text = "Vytvářím spojení s PLC...";

            log.Info("Service_Connected()... OK");
        }