private void buttonReadAddrs_Click(object sender, EventArgs e)
 {
     labelState.Text = "参数读取中...";
     DataCollection.montrParamState       = 0;
     DataCollection.ComStructData.TxLen   = ProtocoltyParam.EncodeFrame(7);    //向监视器下发读地址
     DataCollection.ComStructData.TX_TASK = true;
 }
        private void buttonIpConfig_Click(object sender, EventArgs e)
        {
            DataCollection.montrParamState = 0;
            labelState.Text = "参数下设中...";
            DataCollection.GPRSComSet.main_IP[0] = byte.Parse(textBoxMainIP1.Text);
            DataCollection.GPRSComSet.main_IP[1] = byte.Parse(textBoxMainIP2.Text);
            DataCollection.GPRSComSet.main_IP[2] = byte.Parse(textBoxMainIP3.Text);
            DataCollection.GPRSComSet.main_IP[3] = byte.Parse(textBoxMainIP4.Text);
            DataCollection.GPRSComSet.main_Port  = UInt16.Parse(textBoxMainPort.Text);

            DataCollection.GPRSComSet.res_IP[0] = byte.Parse(textBoxResIP1.Text);
            DataCollection.GPRSComSet.res_IP[1] = byte.Parse(textBoxResIP2.Text);
            DataCollection.GPRSComSet.res_IP[2] = byte.Parse(textBoxResIP3.Text);
            DataCollection.GPRSComSet.res_IP[3] = byte.Parse(textBoxResIP4.Text);
            DataCollection.GPRSComSet.res_Port  = UInt16.Parse(textBoxResPort.Text);

            if (textBoxAPN.Text.Length < 16)
            {
                for (int i = 0; i < textBoxAPN.Text.Length; i++)
                {
                    DataCollection.GPRSComSet.APN[i] = textBoxAPN.Text[i];
                }
                DataCollection.GPRSComSet.APN[textBoxAPN.Text.Length] = '\0';
            }
            else
            {
                MessageBox.Show("APN输入错误!");
                return;
            }

            DataCollection.ComStructData.TxLen   = ProtocoltyParam.EncodeFrame(2);    //向监视器下发监视端ip参数
            DataCollection.ComStructData.TX_TASK = true;
        }
        //指示器参数设置
        private void button1_Click(object sender, EventArgs e)
        {
            labelState.Text = "参数设置中...";
            DataCollection.indtrParamState = 0;
            int index = getIndex();

            DataCollection.quickBreakSwitch[index]   = UInt16.Parse(textBoxSuDuanSwitch.Text);
            DataCollection.quickBreakValue[index]    = UInt16.Parse(textBoxSuDuanSet.Text);
            DataCollection.quickBreakTime[index]     = UInt16.Parse(textBoxSuDuanTimeSet.Text);
            DataCollection.overCurrentSwitch[index]  = UInt16.Parse(textBoxGuoLiuSwitch.Text);
            DataCollection.overCurrentValue[index]   = UInt16.Parse(textBoxGuoLiuSet.Text);
            DataCollection.overCurrentTime[index]    = UInt16.Parse(textBoxGuoLiuTimeSet.Text);
            DataCollection.freeCurrentValue[index]   = UInt16.Parse(textBoxWuLiuSet.Text);
            DataCollection.freeCurrentTime[index]    = UInt16.Parse(textBoxWuLiuTimeSet.Text);
            DataCollection.flashyFlowTime[index]     = UInt16.Parse(textBoxYongLiuTimeSet.Text);
            DataCollection.selfAdaptionSwitch[index] = UInt16.Parse(textBoxSelfAdapSwitch.Text);
            DataCollection.indtrAdds[index]          = UInt16.Parse(textBoxIndicatorAddr.Text);
            DataCollection.rate[index]           = UInt16.Parse(textBoxRate.Text);
            DataCollection.bandWidth[index]      = UInt16.Parse(textBoxBandWidth.Text);
            DataCollection.tgz[index]            = UInt16.Parse(textBoxTgz.Text);
            DataCollection.tfgs[index]           = UInt16.Parse(textBoxTfgs.Text);
            DataCollection.res3[index]           = UInt16.Parse(textBoxRes3.Text);
            DataCollection.res4[index]           = UInt16.Parse(textBoxRes4.Text);
            DataCollection.ComStructData.TxLen   = ProtocoltyParam.ParamEncodeFrame(1, index);
            DataCollection.ComStructData.TX_TASK = true;
        }
        //指示器参数读取
        private void buttonRead1_Click(object sender, EventArgs e)
        {
            labelState.Text = "参数读取中...";
            DataCollection.indtrParamState = 0;
            int index = getIndex();

            DataCollection.ComStructData.TxLen   = ProtocoltyParam.ParamEncodeFrame(3, index);
            DataCollection.ComStructData.TX_TASK = true;
        }
        //指示器标志位设置
        private void button2_Click(object sender, EventArgs e)
        {
            labelState.Text = "参数设置中...";
            DataCollection.indtrParamState = 0;
            int index = getIndex();

            DataCollection.manualReset[index]    = byte.Parse(textBoxManualreset.Text);
            DataCollection.calibration[index]    = byte.Parse(textBoxJiaoZhun.Text);
            DataCollection.res1[index]           = byte.Parse(textBoxRes1.Text);
            DataCollection.res2[index]           = byte.Parse(textBoxRes2.Text);
            DataCollection.ComStructData.TxLen   = ProtocoltyParam.ParamEncodeFrame(2, index);
            DataCollection.ComStructData.TX_TASK = true;
        }
 private void buttonAddr_Click(object sender, EventArgs e)
 {
     DataCollection.montrParamState = 0;
     labelState.Text = "参数下设中...";
     DataCollection.MonitorAddrs.addrA1   = int.Parse(textBoxAddrA1.Text);
     DataCollection.MonitorAddrs.addrA2   = int.Parse(textBoxAddrA2.Text);
     DataCollection.MonitorAddrs.addrA3   = int.Parse(textBoxAddrA3.Text);
     DataCollection.MonitorAddrs.addrB1   = int.Parse(textBoxAddrB1.Text);
     DataCollection.MonitorAddrs.addrB2   = int.Parse(textBoxAddrB2.Text);
     DataCollection.MonitorAddrs.addrB3   = int.Parse(textBoxAddrB3.Text);
     DataCollection.MonitorAddrs.addrC1   = int.Parse(textBoxAddrC1.Text);
     DataCollection.MonitorAddrs.addrC2   = int.Parse(textBoxAddrC2.Text);
     DataCollection.MonitorAddrs.addrC3   = int.Parse(textBoxAddrC3.Text);
     DataCollection.ComStructData.TxLen   = ProtocoltyParam.EncodeFrame(6);    //向监视器下发修改地址参数
     DataCollection.ComStructData.TX_TASK = true;
 }
 private void buttonSysParam_Click(object sender, EventArgs e)
 {
     DataCollection.montrParamState = 0;
     labelState.Text = "参数下设中...";
     DataCollection.SystemParam.AddrByteNum_101   = byte.Parse(textBoxAddrByteNum.Text);
     DataCollection.SystemParam.CauseByteNum_101  = byte.Parse(textBoxCauseByteNum.Text);
     DataCollection.SystemParam.PubAddByteNum_101 = byte.Parse(textBoxPubAddByteNum.Text);
     DataCollection.SystemParam.Addr                = UInt16.Parse(textBoxAddr.Text);
     DataCollection.SystemParam.HeartBeatTime       = UInt16.Parse(textBoxHeartBeatTime.Text);
     DataCollection.SystemParam.BeatCycle           = UInt16.Parse(textBoxBeatCycle.Text);
     DataCollection.SystemParam.ComFrameSTime       = UInt16.Parse(textBoxComFrameSTime.Text);
     DataCollection.SystemParam.NormalVoltageRating = UInt16.Parse(textBoxNormalVoltageRating.Text);
     DataCollection.SystemParam.NormalCurrentRating = UInt16.Parse(textBoxNormalCurrentRating.Text);
     DataCollection.SystemParam.PubAddr_101         = UInt16.Parse(textBoxPubAddr.Text);
     DataCollection.SystemParam.RequestTime         = UInt16.Parse(textBoxRequestTime.Text);
     DataCollection.ComStructData.TxLen             = ProtocoltyParam.EncodeFrame(1); //向监视器下发监视端系统参数
     DataCollection.ComStructData.TX_TASK           = true;
 }