コード例 #1
0
        private void OnGetDOData(string rawData)
        {
            var dateObj = AdvantechHttpWebUtility.ParserJsonToObj <DOSlotValueData>(rawData);

            UpdateDOUIStatus(dateObj);
            InvokeReadStatus();
        }
コード例 #2
0
        private void OnGetDIData(string rawData)
        {
            var dateObj = AdvantechHttpWebUtility.ParserJsonToObj <DISlotValueData>(rawData);

            UpdateDIUIStatus(dateObj);
            if (this.m_iDoTotal > 0)
            {
                GetDOValue();
            }
            else
            {
                InvokeReadStatus();
            }
        }
コード例 #3
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         = "10.0.0.1"; // device IP address
            m_iPort        = 80;         // http port is 80
            m_szAccount    = "root";     // Login account
            m_szPassword   = "******"; // Login password
            m_iPollingTime = 1000;
            m_iSlot        = 0;          //Device localhost default slot is 0

            //m_WISE4000Type = WISEType.WISE4050LAN; // the sample is for WISE-4050/LAN
            //m_WISE4000Type = WISEType.WISE4050; // the sample is for Wise-4050
            m_WISE4000Type = WISEType.WISE4051; // the sample is for Wise-4051
            //m_WISE4000Type = WISEType.WISE4060LAN; // the sample is for Wise-4060/LAN
            // m_WISE4000Type = WISEType.WISE4060; // the sample is for Wise-4060

            txtModule.Text = m_WISE4000Type.ToString();
            m_textBoxList  = new List <TextBox>();
            m_textBoxList.Add(txtCh0);  m_textBoxList.Add(txtCh1);
            m_textBoxList.Add(txtCh2);  m_textBoxList.Add(txtCh3);
            m_textBoxList.Add(txtCh4);  m_textBoxList.Add(txtCh5);
            m_textBoxList.Add(txtCh6);  m_textBoxList.Add(txtCh7);
            m_textBoxList.Add(txtCh8);  m_textBoxList.Add(txtCh9);
            m_textBoxList.Add(txtCh10); m_textBoxList.Add(txtCh11);
            m_HttpRequestDI = new AdvantechHttpWebUtility();
            m_HttpRequestDI.ResquestOccurredError += this.OnGetDIHttpRequestError;
            m_HttpRequestDI.ResquestResponded     += this.OnGetDIData;
            m_HttpRequestDO = new AdvantechHttpWebUtility();
            m_HttpRequestDO.ResquestOccurredError += this.OnGetDOHttpRequestError;
            m_HttpRequestDO.ResquestResponded     += this.OnGetDOData;
            IniWISE_DIO();
        }
コード例 #4
0
        private void btnCh_Click(int i_iCh, TextBox txtBox)
        {
            DOSetValueData doData = new DOSetValueData()
            {
                Val = (uint)((txtBox.Text == "1") ? 0 : 1)
            };                                                                                           // was ON, now set to OFF };
            int iChannel = i_iCh - m_iDiTotal;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string sz_Jsonify = serializer.Serialize(doData);

            try
            {
                AdvantechHttpWebUtility httpRequest = new AdvantechHttpWebUtility();
                httpRequest.SendPATCHRequest(m_szAccount, m_szPassword, GetURL(m_szIP, m_iPort, WISE_RESTFUL_URI.do_value + "/slot_" + m_iSlot + "/ch_" + iChannel), sz_Jsonify);
            }
            catch
            {
                MessageBox.Show("Set digital output failed!", "Error");
            }
            finally
            {
                System.GC.Collect();
            }
        }