示例#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)//has DO
            {
                GetDOValue();
            }
            else
            {
                InvokeReadStatus();
            }
        }
示例#3
0
        private void OnGetAIData(string rawData)
        {
            var dateObj = AdvantechHttpWebUtility.ParserJsonToObj <AISlotValueData>(rawData);

            UpdateAIUIStatus(dateObj);
            if (this.m_iDiTotal > 0 || m_bUDiChannelOccurs)
            {
                GetDIValue();
            }
            else if (this.m_iDoTotal > 0)
            {
                GetDOValue();
            }
            else
            {
                InvokeReadStatus();
            }
        }
示例#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();
            }
        }
示例#5
0
        public Form1()
        {
            InitializeComponent();
            m_iUDiRangeCode = 480;
            m_bStart        = false;         // the action stops at the beginning
            m_szIP          = "192.168.1.1"; // device IP address
            m_iPort         = 80;            // Http port is 80
            m_szAccount     = "root";        // Login account
            m_szPassword    = "******";    // Login password
            m_iSlot         = 0;             //Device localhost default slot is 0
            m_iPollingTime  = 1000;

            m_HttpRequestAI = new AdvantechHttpWebUtility();
            m_HttpRequestAI.ResquestOccurredError += this.OnGetAIHttpRequestError;//Delegate callback for resquest value occurred error
            m_HttpRequestAI.ResquestResponded     += this.OnGetAIData;

            m_HttpRequestDI = new AdvantechHttpWebUtility();
            m_HttpRequestDI.ResquestOccurredError += this.OnGetDIHttpRequestError;//Delegate callback for resquest value occurred error
            m_HttpRequestDI.ResquestResponded     += this.OnGetDIData;


            m_HttpRequestDO = new AdvantechHttpWebUtility();
            m_HttpRequestDO.ResquestOccurredError += this.OnGetDOHttpRequestError;//Delegate callback for resquest value occurred error
            m_HttpRequestDO.ResquestResponded     += this.OnGetDOData;

            //m_WISEType = WISEType.WISE4012E; // the sample is for WISE-4012E
            m_WISEType = WISEType.WISE4012; // the sample is for WISE-4012
            //m_WISEType = WISEType.WISE4010LAN; // the sample is for WISE-4010LAN

            m_UDiChannelList = new List <UiChannelInfo>();
            m_AITextBoxList  = new List <TextBox>();
            m_AICheckboxList = new List <CheckBox>();
            m_DIOTextBoxList = new List <TextBox>();
            m_AIPanelList    = new List <Panel>();
            m_DIOPanelList   = new List <Panel>();
            m_DIOBtnList     = new List <Button>();

            m_DIOBtnList.Add(this.btnCh0); m_DIOBtnList.Add(this.btnCh1);
            m_DIOBtnList.Add(this.btnCh2); m_DIOBtnList.Add(this.btnCh3);

            m_AIPanelList.Add(this.panelAI0); m_AIPanelList.Add(this.panelAI1);
            m_AIPanelList.Add(this.panelAI2); m_AIPanelList.Add(this.panelAI3);

            m_DIOPanelList.Add(this.panelDIO0); m_DIOPanelList.Add(this.panelDIO1);
            m_DIOPanelList.Add(this.panelDIO2); m_DIOPanelList.Add(this.panelDIO3);

            m_AITextBoxList.Add(this.txtAIValue0); m_AITextBoxList.Add(this.txtAIValue1);
            m_AITextBoxList.Add(this.txtAIValue2); m_AITextBoxList.Add(this.txtAIValue3);

            m_AICheckboxList.Add(this.chkboxCh0); m_AICheckboxList.Add(this.chkboxCh1);
            m_AICheckboxList.Add(this.chkboxCh2); m_AICheckboxList.Add(this.chkboxCh3);

            m_DIOTextBoxList.Add(this.txtDIOValue0); m_DIOTextBoxList.Add(this.txtDIOValue1);
            m_DIOTextBoxList.Add(this.txtDIOValue2); m_DIOTextBoxList.Add(this.txtDIOValue3);

            txtModule.Text = m_WISEType.ToString();

            // arrange channel text box

            if (m_WISEType == WISEType.WISE4012)
            {
                Initial_WISE_4012();
            }
            else if (m_WISEType == WISEType.WISE4012E)
            {
                Initial_WISE_4012E();
            }
            else
            {
                Initial_WISE_4010LAN();
            }
        }