Пример #1
0
        public void connect(CpsNet _cpsNet)
        {
            reconnect_counter++;
            cpsNet       = _cpsNet;
            DicSensorVal = new Dictionary <short, float>();

            if (client_udp != null)
            {
                if (client_udp.RemoteIp != _ip)
                {
                    client_udp.RemoteIp = _ip;
                }
                if (client_udp.RemotePort != _port)
                {
                    client_udp.RemotePort = _port;
                }
            }
            else
            {
                client_udp = cpsNet.newClient(_ip, _port.ToString());
            }

            Frame f = new Frame(client_udp);

            f.SetHeaderFlag(FrameHeaderFlag.SYNC);
            send(f);
            //initRequestTimer();

            //SendMsg = new Thread(new ThreadStart(initRequestTimer));
            //SendMsg.IsBackground = true;

            //SendMsg.Start();
        }
Пример #2
0
        public FrmPlcClient(object plc, object cpsNet)
        {
            InitializeComponent();
            _plc      = (plc)plc;
            _cpsNet   = (CpsNet)cpsNet;
            this.Text = _plc.NamePlc;
            init_timer();

            comboBox_headerFlag.DataSource = Enum.GetValues(typeof(FrameHeaderFlag));
        }
Пример #3
0
        public FrmCPS(CpsNet c)
        {
            if (c != null)
            {
                CpsNet = c;
            }
            else
            {
                return;
            }

            InitializeComponent();

            string HostName = System.Net.Dns.GetHostName();

            System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostEntry(HostName);

            label_host_name.Text = HostName;
            foreach (System.Net.IPAddress ip in hostInfo.AddressList)
            {
                comboBox_local_ips.Items.Add(ip.ToString());
            }

            //CpsNet.serverSTART(textBox_srv_port.Text);

            //init_TimerUpdateGui();
            //TimerUpdateGui.Start();

            listBox_frameLog.DataSource = ListFrames;

            textBox_MaxSYNCResendTrys.Text      = CpsNet.MaxSYNCResendTrys.ToString();
            textBox_WATCHDOG_WORK.Text          = CpsNet.WATCHDOG_WORK.ToString();
            checkBox_SendFramesCallback.Checked = CpsNet.SendFramesCallback;
            //checkBox_SendOnlyIfConnected.Checked = CpsNet.SendOnlyIfConnected;
            checkBox_send_big_endian.Checked = Frame._RemoteIsBigEndian;


            makeNewClient();
            comboBox_listClients.SelectedIndex = 0;
        }