Exemplo n.º 1
0
        public void Receive_Data_Check(byte[] data)
        {
            _101_function _101_Function = new _101_function();

            if ((data[0] != (byte)_101_config.IEC_101_Msg.variable_state_code) && (data[0] != (byte)_101_config.IEC_101_Msg.fixed_state_code))
            {
                return;
            }
            try
            {
                int start = 0;
                while (start < data.Length)
                {
                    int    n        = _101_Function.Data_Check(data, start);
                    byte[] databuff = new byte[n];
                    for (int i = 0; i < n; i++, start++)
                    {
                        databuff[i] = data[start];
                    }
                    SerialPort_config.Analysis_msg(databuff, databuff.Length);//显示报文解析
                    Receive_Data_Handle(databuff);
                }
            }
            catch {
                return;
            }
        }
Exemplo n.º 2
0
        private void ToolStripMenuItem4_Click(object sender, EventArgs e)
        {
            _101_function _101_Function = new _101_function();
            string        time          = System.DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss");

            saveFileDialog1.FileName = time;//文件名字
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                _101_Function.Save_Data(saveFileDialog1.FileName, richTextBox1.Text);
            }
        }
Exemplo n.º 3
0
        private void Send_Data_Transmit(byte[] data, int len)
        {
            _101_function _101_Function = new _101_function();

            if (data[0] == (byte)_101_config.IEC_101_Msg.fixed_state_code)
            {
                data[len++] = _101_Function.Get_CS(data, 1, 3);
            }
            else
            {
                data[len++] = _101_Function.Get_CS(data, 4, len - 4);
            }
            data[len++] = (byte)_101_config.IEC_101_Msg.end_code;

            SerialPort_config serialPort = new SerialPort_config();

            serialPort.Send_Data(data, len);
        }
Exemplo n.º 4
0
        public static void Analysis_msg(byte [] data, int n)
        {
            _101_function _101_Function = new _101_function();

            _101_Function.Show_Data(data, n, textbox);
        }