private void Send_Data_Variable_YK() { byte[] data = new byte[256]; int n = 0; data[n] = (int)_101_config.IEC_101_Msg.variable_state_code; n += 3; data[n++] = (int)_101_config.IEC_101_Msg.variable_state_code; data[n++] = _101_function.Data_Get_Cctrl(1, _101_config.FCB, 1, (int)_101_config.IEC101_CDIR_LK_CODE.FUN_SD); _101_function.number_to_octets(ref data, n, _101_config.ipaddr, _101_config.ipaddr_size); n += _101_config.ipaddr_size; data[n++] = (byte)YK.Get_Type(); data[n++] = 1; _101_function.number_to_octets(ref data, n, YK.Get_Cot(), _101_config.cotsize); n += _101_config.cotsize; _101_function.number_to_octets(ref data, n, _101_config.asduaddr, _101_config.asduaddr_size); n += _101_config.asduaddr_size; _101_function.number_to_octets(ref data, n, YK.Get_Infaddr(), _101_config.infaddr_size); n += _101_config.infaddr_size; //单双命令 data[n++] = YK.Get_YK_SCO_DCO(); data[1] = data[2] = (byte)(n - 4); Send_Data_Transmit(data, n); }
private void Data_Handle_Variable_YK(byte [] data) { int n = 6 + _101_config.ipaddr_size; byte SQ = data[n++]; int cot = _101_function.octets_to_number(data, n, _101_config.cotsize); n += _101_config.cotsize; int asduaddr = _101_function.octets_to_number(data, n, _101_config.asduaddr_size); n += _101_config.asduaddr_size; int infaddr = _101_function.octets_to_number(data, n, _101_config.infaddr_size); n += _101_config.infaddr_size; byte SCODCO = data[n++]; if (infaddr != YK.Get_Infaddr())//信息体地址错误 { return; } if (SCODCO != YK.Get_YK_SCO_DCO())//命令词错误 { return; } _101_config.process = (int)_101_config.IEC_101_Process.END; YK.select = true; }