public static PARAM_C1G2Write FromXmlNode(XmlNode node) { string val; PARAM_C1G2Write param = new PARAM_C1G2Write(); val = XmlUtil.GetNodeValue(node, "OpSpecID"); param.OpSpecID = Convert.ToUInt16(val); val = XmlUtil.GetNodeValue(node, "AccessPassword"); param.AccessPassword = Convert.ToUInt32(val); val = XmlUtil.GetNodeValue(node, "MB"); param.MB = TwoBits.FromString(val); val = XmlUtil.GetNodeValue(node, "WordPointer"); param.WordPointer = Convert.ToUInt16(val); val = XmlUtil.GetNodeValue(node, "WriteData"); param.WriteData = UInt16Array.FromString(val); return param; }
private static void AddWriteAccessCommand(MSG_ADD_ACCESSSPEC msg, string data) { //define access spec msg.AccessSpec.AccessCommand.AccessCommandOpSpec = new UNION_AccessCommandOpSpec(); PARAM_C1G2Write wr = new PARAM_C1G2Write(); wr.AccessPassword = 0; wr.MB = new TwoBits(1); wr.OpSpecID = 111; wr.WordPointer = 2; //Data to be written. ex: "EEEE11112222333344445555" wr.WriteData = UInt16Array.FromString(data); msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr); }
public new static PARAM_C1G2Write FromBitArray(ref BitArray bit_array, ref int cursor, int length) { if (cursor >= length) return null; int field_len = 0; object obj_val; int parameter_len = 0; ArrayList param_list = new ArrayList(); PARAM_C1G2Write param = new PARAM_C1G2Write(); int param_type = 0; if (bit_array[cursor]) param.tvCoding = true; if (param.tvCoding) { cursor++; param_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 7); if (param_type != param.TypeID) { cursor -= 8; return null; } } else { cursor += 6; param_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 10); if (param_type != param.TypeID) { cursor -= 16; return null; } param.length = (UInt16)(int)Util.DetermineFieldLength(ref bit_array, ref cursor); } if (cursor > length) throw new Exception("Input data is not complete message"); field_len = 16; Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt16), field_len); param.OpSpecID = (UInt16)obj_val; if (cursor > length) throw new Exception("Input data is not complete message"); field_len = 32; Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt32), field_len); param.AccessPassword = (UInt32)obj_val; if (cursor > length) throw new Exception("Input data is not complete message"); field_len = 2; Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(TwoBits), field_len); param.MB = (TwoBits)obj_val; cursor += param_reserved_len; if (cursor > length) throw new Exception("Input data is not complete message"); field_len = 16; Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt16), field_len); param.WordPointer = (UInt16)obj_val; if (cursor > length) throw new Exception("Input data is not complete message"); field_len = Util.DetermineFieldLength(ref bit_array, ref cursor); Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt16Array), field_len); param.WriteData = (UInt16Array)obj_val; return param; }