コード例 #1
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if (btnConnect.Text == "Connect")
     {
         if (adamSk.Connect(txtIP.Text, m_protocol, m_iPort))
         {
             adamSk.SetTimeout(2000, 2000, 2000);
             txtSend.Enabled = true;
             btnSend.Enabled = true;
             txtIP.Enabled   = false;
             btnConnect.Text = "Disconnect";
         }
         else
         {
             MessageBox.Show("Failed to connect module!", "Error");
         }
     }
     else
     {
         adamSk.Disconnect();
         txtSend.Enabled = false;
         btnSend.Enabled = false;
         txtIP.Enabled   = true;
         btnConnect.Text = "Connect";
     }
 }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            int iIdx;

            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.200";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6024;  // the sample is for ADAM-6050

            // modbus current list view item
            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDiTotal = DigitalInput.GetChannelTotal(m_Adam6000Type);
            m_iAoTotal = AnalogOutput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            m_bChEnabled = new bool[m_iAiTotal];
            m_byAiRange  = new byte[m_iAiTotal];
            m_byAoRange  = new byte[m_iAoTotal];

            for (iIdx = 0; iIdx < m_iAoTotal; iIdx++)
            {
                //
                cbxAOChannel.Items.Add(iIdx.ToString());
                //
            }
            cbxAOChannel.SelectedIndex = -1;

            txtModule.Text = m_Adam6000Type.ToString();
        }
コード例 #3
0
ファイル: ad.cs プロジェクト: fengxing1121/_cefanshiyantai
        public void info()
        {
            #region 定义模块参数
            // m_bStart = false;			// the action stops at the beginning
            m_szIP1 = "10.0.0.2";                           // modbus slave IP address
            m_szIP2 = "10.0.0.3";                           // modbus slave IP address
            m_szIP3 = "10.0.0.4";                           // modbus slave IP address
            m_szIP4 = "10.0.0.5";                           // modbus slave IP address
            m_szIP5 = "10.0.0.6";                           // modbus slave IP address
            m_szIP6 = "10.0.0.7";                           // modbus slave IP address
            m_szIP7 = "10.0.0.8";                           // modbus slave IP address
            m_szIP8 = "10.0.0.9";                           // modbus slave IP address
            m_szIP9 = "10.0.0.10";                          // modbus slave IP address

            m_iPort     = 502;                              // modbus TCP port is 502
            adamModbus1 = new AdamSocket();
            adamModbus1.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus1.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus2 = new AdamSocket();
            adamModbus2.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus2.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus3 = new AdamSocket();
            adamModbus3.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus3.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus4 = new AdamSocket();
            adamModbus4.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus4.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus5 = new AdamSocket();
            adamModbus5.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus5.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus6 = new AdamSocket();
            adamModbus6.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus6.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus7 = new AdamSocket();
            adamModbus7.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus7.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus8 = new AdamSocket();
            adamModbus8.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus8.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            adamModbus9 = new AdamSocket();
            adamModbus9.SetTimeout(500, 500, 500);          // 设置超时时间
            adamModbus9.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for  ADAM-6217

            m_Adam6000Type = Adam6000Type.Adam6217;         // the sample is for ADAM-6217
            m_iAiTotal     = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_bChEnabled   = new bool[m_iAiTotal];
            m_byRange      = new ushort[m_iAiTotal];
            #endregion

            red_net = new Thread(red);
            red_net.Start();
        }
コード例 #4
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         modbusClient = new ModbusClient(txtIP.Text, 502);    //Ip-Address and Port of Modbus-TCP-Server
         modbusClient.Connect();
         if (modbusClient.Connected)
         {
             lblStatus.Text = "Connected";
             timer2.Enabled = true;
         }
         _AdamModbus = new AdamSocket();
         _AdamModbus.SetTimeout(1000, 1000, 1000);
         _AdamModbus.Connect(txtIpAdam.Text, ProtocolType.Tcp, 502);
         //if (_AdamModbus.Connect(txtIpAdam.Text, ProtocolType.Tcp, 502))
         //{
         //    lblStatusAdam.Text = "Connected";
         //}
     }
     catch (Exception ex)
     {
         timer2.Enabled = false;
         lblStatus.Text = ex.ToString();
         throw;
     }
 }
コード例 #5
0
        //public string HelloWorld()
        //{
        //    return "Hello World";
        //}

        public void adamconnect(string varIPAddress, string varPortNo)
        {
            try
            {
                m_bStart = false;

                m_szIP     = varIPAddress;               // GlobalVariable.strDIOIPAddress_glb;
                m_iPort    = Convert.ToInt32(varPortNo); // GlobalVariable.strDIOPortNumber_glb);
                adamModbus = new AdamSocket();
                adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
                m_Adam6000Type = Adam6000Type.Adam6066;  //InitAdam6066();
                int iDI = 12, iDO = 2;
                m_iDoTotal = iDO;
                m_iDiTotal = iDI;
                if (adamModbus.Connect(m_szIP, ProtocolType.Tcp, m_iPort))
                {
                    // panelDIO.Enabled = true;
                    m_iCount = 0;    // reset the reading counter
                    //timer1.Enabled = true; // enable timer
                    m_bStart = true; // starting flag
                }
                else
                {
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Adam is not connected. Please check.');", true);
                }
            }
            catch { }
        }
コード例 #6
0
        public Form1()
        {
            InitializeComponent();

            m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP
            if (m_b5000)
            {
                m_iCom           = 4;     // using COM4
                adamCom          = new AdamCom(m_iCom);
                adamCom.Checksum = false; // disbale checksum
            }
            else
            {
                m_szIP     = "172.18.3.179";
                adamSocket = new AdamSocket();
                adamSocket.SetTimeout(1000, 1000, 1000); // set timeout
            }
            m_iAddr        = 3;                          // the slave address is 1
            m_iSlot        = 0;                          // the slot index of the module
            m_iCount       = 0;                          // the counting start from 0
            m_bStart       = false;
            m_Adam5000Type = Adam5000Type.Adam5017H;     // the sample is for ADAM-5017H
            //m_Adam5000Type = Adam5000Type.Adam5017UH; // the sample is for ADAM-5017UH
            //m_Adam5000Type = Adam5000Type.Adam5018P; // the sample is for ADAM-5018P

            m_iChTotal     = AnalogInput.GetChannelTotal(m_Adam5000Type);
            m_byRange      = new byte[m_iChTotal];
            txtModule.Text = m_Adam5000Type.ToString();
            //
            if (m_Adam5000Type == Adam5000Type.Adam5018P)
            {
                chkboxCh7.Visible   = false;
                txtAIValue7.Visible = false;
            }
        }
コード例 #7
0
ファイル: ModbusTCPService.cs プロジェクト: windygu/ADAM_APAX
        public bool ModbusConnection(DeviceModel obj)
        {
            if (obj.IPAddress == "" || obj.IPAddress == null)
            {
                return(false);
            }

            Device = new DeviceModel()//20150626 建立一個DeviceModel給所有Service
            {
                IPAddress = obj.IPAddress,
                Port      = 1,//obj.ModbusAddr,
                //ModbusTimeOut = 3000,//obj.ModbusTimeOut,
                //MbCoils = obj.MbCoils,
                //MbRegs = obj.MbRegs,
            };

            //
            adamTCP = new AdamSocket();
            adamTCP.SetTimeout(1000, Device.Port, modbusTimeout); // set timeout for TCP
            if (adamTCP.Connect(Device.IPAddress, ProtocolType.Tcp, m_iPort))
            {
                m_connFlg = true;
                return(true);
            }
            m_connFlg = false;
            return(false);
        }
コード例 #8
0
        public Form1()
        {
            InitializeComponent();

            int iIdx;

            m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP
            if (m_b5000)
            {
                m_iCom           = 2;     // using COM2
                adamCom          = new AdamCom(m_iCom);
                adamCom.Checksum = false; // disbale checksum
            }
            else
            {
                m_szIP     = "172.18.3.179";
                adamSocket = new AdamSocket();
                adamSocket.SetTimeout(1000, 1000, 1000); // set timeout
            }
            m_iAddr        = 1;                          // the slave address is 1
            m_iSlot        = 0;                          // the slot index of the module
            m_iCount       = 0;                          // the counting start from 0
            m_bStart       = false;
            m_Adam5000Type = Adam5000Type.Adam5080;      // the sample is for ADAM-5080

            m_iChTotal = Counter.GetChannelTotal(m_Adam5000Type);
            for (iIdx = 0; iIdx < m_iChTotal; iIdx++)
            {
                cbxChannel.Items.Add(iIdx.ToString());
            }
            txtModule.Text = m_Adam5000Type.ToString();
        }
コード例 #9
0
        public Form1()
        {
            InitializeComponent();

            m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP
            if (m_b5000)
            {
                m_iCom           = 2;     // using COM2
                adamCom          = new AdamCom(m_iCom);
                adamCom.Checksum = false; // disbale checksum
            }
            else
            {
                m_szIP     = "172.19.1.234";
                adamSocket = new AdamSocket();
                adamSocket.SetTimeout(1000, 1000, 1000); // set timeout
            }
            m_iAddr  = 1;                                // the slave address is 1
            m_iSlot  = 1;                                // the slot index of the module
            m_iCount = 0;                                // the counting start from 0
            m_bStart = false;
            //m_Adam5000Type = Adam5000Type.Adam5050; // the sample is for ADAM-5050
            m_Adam5000Type = Adam5000Type.Adam5051; // the sample is for ADAM-5051
            //m_Adam5000Type = Adam5000Type.Adam5052; // the sample is for ADAM-5052
            //m_Adam5000Type = Adam5000Type.Adam5055; // the sample is for ADAM-5055
            //m_Adam5000Type = Adam5000Type.Adam5056; // the sample is for ADAM-5056
            //m_Adam5000Type = Adam5000Type.Adam5060; // the sample is for ADAM-5060
            //m_Adam5000Type = Adam5000Type.Adam5068; // the sample is for ADAM-5068
            //m_Adam5000Type = Adam5000Type.Adam5069; // the sample is for ADAM-5069

            m_iChTotal     = DigitalInput.GetChannelTotal(m_Adam5000Type) + DigitalOutput.GetChannelTotal(m_Adam5000Type);
            txtModule.Text = m_Adam5000Type.ToString();
        }
コード例 #10
0
        private ushort[] m_usRange; //for newer version
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new CpDashboardDatabaseInitializer());

            RouteTable.Routes.MapHttpRoute(
                name: "Alert",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = System.Web.Http.RouteParameter.Optional }
                );

            CpDashboardContext cont = new CpDashboardContext();

            cont.Database.Initialize(true);
            cont.Database.CreateIfNotExists();

            //set a timer
            //adam initializer
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "192.168.10.10";            // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            //txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled = new bool[m_iAiTotal];

            //firmware version
            //fwversion.Text = m_DeviceFwVer.ToString();

            if (m_DeviceFwVer > m_Adam6000NewerFwVer)
            {
                m_usRange = new ushort[m_iAiTotal];
            }

            if (cont.Database.Exists())
            {
                // start the retrieving datas and save to db;
                startSending();
            }
        }
コード例 #11
0
        //było 6

        public void EstablishConnection()
        {
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "10.35.5.221";              // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            InitAdam6060();
            Console.WriteLine("Połączono");
        }
コード例 #12
0
        private bool GetSerialComPortTcpPortMapping(int i_intSlotId, out int[] o_tcpPortMappingAry)
        {
            bool bRet = false;

            o_tcpPortMappingAry = new int[4];

            if (adamUDP.Connect(m_szIP, ProtocolType.Udp, ASCII_CMD_UDP_PORT))
            {
                adamUDP.SetTimeout(m_iConnectTimeout, m_iSendTimeout, m_iReceiveTimeout);

                bRet = adamUDP.Configuration().GetModuleCOMTcpPortMapping(i_intSlotId, out o_tcpPortMappingAry);
            }
            else
            {
                MessageBox.Show("Failed to connect module!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                bRet = false;
            }

            adamUDP.Disconnect();
            return(bRet);
        }
コード例 #13
0
        public AdamCNT()
        {
            cnt          = 0;
            m_szIP       = Constants.DEF_IP;
            m_iPort      = Constants.DEF_PORT;
            m_adamModbus = new AdamSocket();
            m_adamUDP    = new AdamSocket();
            m_adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            m_Adam6000Type = Adam6000Type.Adam6051;    // the sample is for ADAM-6051

            InitAdam6051();
        }
コード例 #14
0
 public bool Adam6060Init(string m_IP, int m_Port)
 {
     adamModbus = new AdamSocket();
     adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
     if (adamModbus.Connect(m_IP, ProtocolType.Tcp, m_Port))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #15
0
 public bool OpenDevice()
 {
     m_adamSocket = new AdamSocket(m_adamType);
     m_adamSocket.SetTimeout(m_iTimeout[0], m_iTimeout[1], m_iTimeout[2]);
     if (m_adamSocket.Connect(m_szIP, protoType, portNum))
     {
         if (!m_adamSocket.Configuration().GetSlotInfo(out m_szSlots))
         {
             this.StatusBar_IO.Text = "GetSlotInfo() Failed! ";
             return(false);
         }
     }
     return(true);
 }
コード例 #16
0
        public Form1()
        {
            InitializeComponent();

            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.232";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6050;  // the sample is for ADAM-6050
            //m_Adam6000Type = Adam6000Type.Adam6050W; // the sample is for ADAM-6050W
            //m_Adam6000Type = Adam6000Type.Adam6051; // the sample is for ADAM-6051
            //m_Adam6000Type = Adam6000Type.Adam6051W; // the sample is for ADAM-6051W
            //m_Adam6000Type = Adam6000Type.Adam6052; // the sample is for ADAM-6052
            //m_Adam6000Type = Adam6000Type.Adam6055; // the sample is for ADAM-6055
            //m_Adam6000Type = Adam6000Type.Adam6060; // the sample is for ADAM-6060
            //m_Adam6000Type = Adam6000Type.Adam6060W; // the sample is for ADAM-6060W
            //m_Adam6000Type = Adam6000Type.Adam6066; // the sample is for ADAM-6066

            if (m_Adam6000Type == Adam6000Type.Adam6050 ||
                m_Adam6000Type == Adam6000Type.Adam6050W)
            {
                InitAdam6050();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6051 ||
                     m_Adam6000Type == Adam6000Type.Adam6051W)
            {
                InitAdam6051();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6052)
            {
                InitAdam6052();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6055)
            {
                InitAdam6055();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6060 ||
                     m_Adam6000Type == Adam6000Type.Adam6060W)
            {
                InitAdam6060();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6066)
            {
                InitAdam6066();
            }

            txtModule.Text = m_Adam6000Type.ToString();
        }
コード例 #17
0
ファイル: paleSubscribe.cs プロジェクト: qq5013/CalSln_Client
 public void initControl()
 {
     m_bStart = false;			// the action stops at the beginning
     m_szIP = "192.168.0.121";	// modbus slave IP address
     m_iPort = 502;				// modbus TCP port is 502
     adamModbus = new AdamSocket();
     adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
     m_iDoTotal = 6;
     m_iDiTotal = 12;
     if (adamModbus.Connect(m_szIP, ProtocolType.Tcp, m_iPort))
     { }
     else
         MessageBox.Show("连接IP地址为 " + m_szIP + " 的开门控制器失败!", "连接失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
コード例 #18
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.93";              // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamModbus.AdamSeriesType = AdamType.Adam6200;
            adamModbus.Connect(m_szIP, ProtocolType.Tcp, m_iPort);

            m_Adam6000Type = Adam6000Type.Adam6224; // the sample is for ADAM-6224

            m_iAoChTotal        = AnalogOutput.GetChannelTotal(m_Adam6000Type);
            m_iAoRangeTotal     = AnalogOutput.GetRangeTotal(m_Adam6000Type, Adam6000_RangeFormat.Ushort);
            m_iDiTotal          = DigitalInput.GetChannelTotal(m_Adam6000Type);
            m_DiValueStartAddr  = 1;
            m_iAoValueStartAddr = 1;
            txtModule.Text      = m_Adam6000Type.ToString();
            m_usRange           = new ushort[m_iAoChTotal];
            m_usAoValue         = new ushort[m_iAoChTotal];

            InitialDiDgViewModbusGeneralRow(m_DiValueStartAddr, m_iDiTotal, ref dgViewDiChannelInfo);

            InitialAoDgViewModbusGeneralRow(m_iAoValueStartAddr, m_iAoChTotal, ref dgViewAoChannelInfo);
            for (int i = 0; i < m_iAoChTotal; i++)
            {
                cbxAoChannel.Items.Add(i.ToString());
            }

            cbxAoChannel.Items.Add("All");

            if (m_Adam6000Type == Adam6000Type.Adam6224)
            {
                for (int i_iIndex = 0; i_iIndex < m_iAoRangeTotal; i_iIndex++)
                {
                    ushort usRangeCode  = AnalogOutput.GetRangeCode2Byte(m_Adam6000Type, i_iIndex);
                    string strRangeName = AnalogOutput.GetRangeName(m_Adam6000Type, usRangeCode);
                    cbxAoOutputRange.Items.Add(new ComboItem(strRangeName, usRangeCode));
                }
            }
        }
コード例 #19
0
ファイル: frmScrII.cs プロジェクト: VKK-cell/Turbo-Edac
 //****************************
 public void Init_TCP_Port()
 {
     m_bRegister1 = true;            // set to true to read the register, otherwise, read the coil
     m_bRegister2 = true;            // set to true to read the register, otherwise, read the coil
     m_IP18       = "192.168.1.241"; // "172.18.3.243";	// modbus slave IP address
     m_IP17       = "192.168.1.242"; //modbus slave IP address
     m_iPort      = 502;             // modbus TCP port is 502
     m_iStart1    = 1;               // modbus starting address
     m_iLength1   = 8;
     m_iStart2    = 1;               // modbus starting address
     m_iLength2   = 8;               // modbus reading length
     adamTCP1     = new AdamSocket();
     adamTCP2     = new AdamSocket();
     adamTCP1.SetTimeout(1000, 1000, 1000); // set timeout for TCP
     adamTCP2.SetTimeout(1000, 1000, 1000); // set timeout for TCP
 }
コード例 #20
0
        public Form1()
        {
            InitializeComponent();

            m_bStart     = false;                      // the action stops at the beginning
            m_szIP       = "10.0.0.1";                 // modbus slave IP address
            m_iPort      = 502;                        // modbus TCP port is 502
            m_adamModbus = new AdamSocket();
            m_adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6051;    // the sample is for ADAM-6051

            InitAdam6051();
            SetModeItem();
            btnEnableDisable(false);
            txtModule.Text = m_Adam6000Type.ToString();
        }
コード例 #21
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.147";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6250;  // the sample is for ADAM-6250
            //m_Adam6000Type = Adam6000Type.Adam6251; // the sample is for ADAM-6251
            //m_Adam6000Type = Adam6000Type.Adam6256; // the sample is for ADAM-6256
            //m_Adam6000Type = Adam6000Type.Adam6260; // the sample is for ADAM-6260
            //m_Adam6000Type = Adam6000Type.Adam6266; // the sample is for ADAM-6266

            txtModule.Text = m_Adam6000Type.ToString();

            if (m_Adam6000Type == Adam6000Type.Adam6250)
            {
                InitAdam6250();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6251)
            {
                InitAdam6251();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6256)
            {
                InitAdam6256();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6260)
            {
                InitAdam6260();
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6266)
            {
                InitAdam6266();
            }
        }
コード例 #22
0
        /// <summary>
        /// Refresh I/O modules of this controller and show controller information
        /// </summary>
        /// <param name="e"></param>
        private void AfterSelect_CouplerDevice(TreeNode e)
        {
            TreeNode adamNode;

            m_adamModbusSocket = new AdamSocket(adamType);
            m_adamModbusSocket.SetTimeout(m_iTimeout[0], m_iTimeout[1], m_iTimeout[2]);
            if (m_adamModbusSocket.Connect(m_szIP, protoType, portNum))
            {
                if (m_adamModbusSocket.RefreshIOInfo())
                {
                    Thread waitThread = new Thread(ShowWaitMsg);
                    waitThread.Start();
                    m_adamModbusSocket.Configuration().GetSlotInfo(out m_szSlotInfo);
                    //
                    treeView1.BeginUpdate();
                    e.Nodes.Clear();
                    for (int iCnt = 0; iCnt < m_szSlotInfo.Length; iCnt++)
                    {
                        if (m_szSlotInfo[iCnt] != null)
                        {
                            adamNode     = new TreeNode(m_szSlotInfo[iCnt] + "(S" + iCnt.ToString() + ")");
                            adamNode.Tag = (byte)iCnt;
                            e.Nodes.Add(adamNode);
                        }
                    }
                    e.ExpandAll();
                    treeView1.EndUpdate();
                    m_adamModbusSocket.GetDSPFWVer(ref m_sDSPFWVer);
                    m_adamModbusSocket.Disconnect();
                }
            }
            else
            {
                MessageBox.Show("Connection error ( Err : " + m_adamModbusSocket.LastError.ToString() + " ). Please check the network setting.", "Error");
                m_adamModbusSocket.Disconnect();
                m_adamModbusSocket = null;
                return;
            }

            RefreshConfiguration();
            m_adamModbusSocket = null;
        }
コード例 #23
0
ファイル: Adam6000.cs プロジェクト: JMatveichik/BatteryTest
        private bool Connect(string ip, int port, int timeout)
        {
            socket = new AdamSocket();
            socket.SetTimeout(timeout, timeout, timeout);

            if (!socket.Connect(ip, ProtocolType.Tcp, port))
            {
                return(false);
            }

            if (AnalogInputs != null)
            {
                RefreshAnalogInputsInfo();
            }

            Port = port;
            IP   = ip;

            return(true);
        }
コード例 #24
0
        public Form1()
        {
            InitializeComponent();

            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.201";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6022;  // the sample is for ADAM-6050

            m_dVals      = new float[3];
            m_pv1LblHigh = new float[2];
            m_pv1LblLow  = new float[2];
            m_pv2LblHigh = new float[2];
            m_pv2LblLow  = new float[2];

            txtModule.Text = m_Adam6000Type.ToString();
        }
コード例 #25
0
        public void Initialize()
        {
            m_bStart   = false;                                         // the action stops at the beginning
            m_szIP     = "192.168.1.3";                                 // modbus slave IP address
            m_iPort    = 502;                                           // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000);                    // set timeout for TCP
            adamModbus.AdamSeriesType = AdamType.Adam6200;              // set AdamSeriesType for  ADAM-6217
            m_Adam6000Type            = Adam6000Type.Adam6217;          // the sample is for ADAM-6217

            m_iAiTotal   = AnalogInput.GetChannelTotal(m_Adam6000Type); //channel number
            m_bChEnabled = new bool[m_iAiTotal];
            m_byRange    = new ushort[m_iAiTotal];

            fValue = new float[m_iAiTotal];
            pool   = new MysqlConnectionPool();


            Connect2Adam();
        }
コード例 #26
0
        public Form1()
        {
            InitializeComponent();

            int iIdx, iPos, iStart;

            m_bStart    = false;                  // the action stops at the beginning
            m_bRegister = true;                   // set to true to read the register, otherwise, read the coil
            m_szIP      = "172.18.3.243";         // modbus slave IP address
            m_iPort     = 502;                    // modbus TCP port is 502
            m_iStart    = 1;                      // modbus starting address
            m_iLength   = 8;                      // modbus reading length
            adamTCP     = new AdamSocket();
            adamTCP.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            // fill the ListView
            if (m_bRegister)               // The initial register list
            {
                iStart = 40000 + m_iStart; // The register starting position  (4X references)
                for (iIdx = 0; iIdx < m_iLength; iIdx++)
                {
                    iPos = iStart + iIdx;
                    listViewModbusCur.Items.Add(new ListViewItem(iPos.ToString()));
                    listViewModbusCur.Items[iIdx].SubItems.Add("Word");
                    listViewModbusCur.Items[iIdx].SubItems.Add("*****");
                    listViewModbusCur.Items[iIdx].SubItems.Add("****");
                }
            }
            else                   // The initial coil list
            {
                iStart = m_iStart; // The coil starting position (0X references)
                for (iIdx = 0; iIdx < m_iLength; iIdx++)
                {
                    iPos = iStart + iIdx;
                    listViewModbusCur.Items.Add(new ListViewItem(iPos.ToString("00000")));
                    listViewModbusCur.Items[iIdx].SubItems.Add("Bit");
                    listViewModbusCur.Items[iIdx].SubItems.Add("*****");
                    listViewModbusCur.Items[iIdx].SubItems.Add("****");
                }
            }
        }
コード例 #27
0
        //int iIdx, iPos, iStart;



        public Form1()
        {
            InitializeComponent();
            // *********************
            //int iIdx, iPos, iStart;

            m_bStart1    = false;           // the action stops at the beginning
            m_bRegister1 = true;            // set to true to read the register, otherwise, read the coil
            m_bStart2    = false;           // the action stops at the beginning
            m_bRegister2 = false;           // set to true to read the register, otherwise, read the coil
            m_IP18       = "192.168.1.241"; // "172.18.3.243";	// modbus slave IP address
            m_IP17       = "192.168.1.242"; //modbus slave IP address
            m_iPort      = 502;             // modbus TCP port is 502
            m_iStart1    = 1;               // modbus starting address
            m_iLength1   = 8;
            m_iStart2    = 1;               // modbus starting address
            m_iLength2   = 8;               // modbus reading length
            adamTCP1     = new AdamSocket();
            adamTCP2     = new AdamSocket();
            adamTCP1.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamTCP2.SetTimeout(1000, 1000, 1000); // set timeout for TCP
        }
コード例 #28
0
        private bool GetSerialComPortTcpPortMapping(int i_intSlotId, out int[] o_tcpPortMappingAry)
        {
            AdamSocket adamSocket = new AdamSocket(AdamType.Apax5070);
            bool       bRet       = false;

            o_tcpPortMappingAry = new int[4];

            if (adamSocket.Connect(m_szIP, ProtocolType.Udp, ASCII_CMD_UDP_PORT))
            {
                adamSocket.SetTimeout(m_iTimeout[0], m_iTimeout[1], m_iTimeout[2]);
                bRet = adamSocket.Configuration().GetModuleCOMTcpPortMapping(i_intSlotId, out o_tcpPortMappingAry);
            }
            else
            {
                //MessageBox.Show("Failed to connect module!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                bRet = false;
            }

            adamSocket.Disconnect();
            adamSocket = null;
            return(bRet);
        }
コード例 #29
0
 private void buttonStart_Click(object sender, EventArgs e)
 {
     if (m_bStart) // was started
     {
         panelDIO.Enabled = false;
         m_bStart         = false;
         timer1.Enabled   = false;
         adamSocket.Disconnect();
         buttonStart.Text = "Start";
     }
     else
     {
         adamSocket.SetTimeout(1000, 1000, 1000);
         if (adamSocket.Connect(m_szIP, ProtocolType.Udp, m_Port))
         {
             // *******************************************
             adamSocket.AdamSeriesType = AdamType.Adam4000; // you have to set this properity to make the command working properly
             // *******************************************
             m_iCount = 0;                                  // reset the reading counter
             // get module config
             if (!adamSocket.Configuration(m_iAddr).GetModuleConfig(out m_adamConfig))
             {
                 adamSocket.Disconnect();
                 MessageBox.Show("Failed to get module config!", "Error");
                 return;
             }
             //
             panelDIO.Enabled = true;
             timer1.Enabled   = true; // enable timer
             buttonStart.Text = "Stop";
             m_bStart         = true; // starting flag
         }
         else
         {
             MessageBox.Show("Failed to connect!", "Error");
         }
     }
 }
コード例 #30
0
        public AdamRetriever(int sensorNum)
        {
            sensorStatus = "false";
            sensorNumber = sensorNum;
            m_bStart     = false;                    // the action stops at the beginning
            m_szIP       = "192.168.10.10";          // modbus slave IP address
            m_iPort      = 502;                      // modbus TCP port is 502
            adamModbus   = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            //txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled = new bool[m_iAiTotal];

            //firmware version
            //fwversion.Text = m_DeviceFwVer.ToString();

            if (m_DeviceFwVer > m_Adam6000NewerFwVer)
            {
                m_usRange = new ushort[m_iAiTotal];
            }

            // start the retrieving datas and save to db;
            startRetrieving();
        }
コード例 #31
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            m_bStart   = false;                                // the action stops at the beginning
            m_szIP     = "172.18.3.189";                       // modbus slave IP address
            m_iPort    = 502;                                  // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000);           // set timeout for TCP
            adamModbus.AdamSeriesType = AdamType.Adam6200;     // set AdamSeriesType for  ADAM-6217
            m_Adam6000Type            = Adam6000Type.Adam6217; // the sample is for ADAM-6217

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);

            txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled   = new bool[m_iAiTotal];
            m_byRange      = new ushort[m_iAiTotal];
        }