Exemplo n.º 1
0
 public frmMain()
 {
     InitializeComponent();
     mbmUdp             = new ModbusMasterUdp();
     mbmUdp.AutoConnect = true;
     mbmUdp.Port        = Convert.ToUInt16(txtPort.Text);
 }
Exemplo n.º 2
0
 public frmMain()
 {
     InitializeComponent();
     cbxBoolValue.SelectedIndex = 0;
     mbmUdp             = new ModbusMasterUdp();
     mbmUdp.AutoConnect = true;
     mbmUdp.Port        = Convert.ToUInt16(txtPort.Text);
 }
Exemplo n.º 3
0
        // The ThreadProc method is called when the thread starts.
        // It loops ten times, writing to the console and yielding
        // the rest of its time slice each time, and then ends.
        public void ThreadProc(object obj)
        {
            ModbusMasterUdp mbmUdpt = new ModbusMasterUdp();

            mbmUdpt.AutoConnect = true;
            mbmUdpt.Port        = 502;
            mbmUdpt.Hostname    = (string)obj;

            bool[] readData;
            wmnRet _wmnReceiveRet = mbmUdpt.ReadCoils(0, 0x3000, 2, out readData);

            if (_wmnReceiveRet.Value == 0)
            {
                for (int i = 0; i < readData.Length; i++)
                {
                    Console.WriteLine(mbmUdpt.Hostname + ":" + mbmUdpt.Port.ToString() + " Address[" + (0x3000 + i).ToString() + "] Value: " + readData[i].ToString() + ";");
                }
            }
            else
            {
                Console.WriteLine(_wmnReceiveRet.Text);
            }
        }