public int GetDiff(EncodeBuffer buffer) { int diff = Math.Abs(buffer.offset - offset); diff = Math.Max(Math.Abs(buffer.serialize_counter - serialize_counter), diff); return(diff); }
public static void EncodeSegmentAck(EncodeBuffer buffer, BacnetPduTypes type, byte original_invoke_id, byte sequence_number, byte actual_window_size) { buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = original_invoke_id; buffer.buffer[buffer.offset++] = sequence_number; buffer.buffer[buffer.offset++] = actual_window_size; }
public EncodeBuffer Copy() { EncodeBuffer ret = new EncodeBuffer(); ret.buffer = buffer; ret.max_offset = max_offset; ret.min_limit = min_limit; ret.offset = offset; ret.result = result; ret.serialize_counter = serialize_counter; ret.expandable = expandable; return(ret); }
public static void EncodeConfirmedServiceRequest(EncodeBuffer buffer, BacnetPduTypes type, BacnetConfirmedServices service, BacnetMaxSegments max_segments, BacnetMaxApdu max_adpu, byte invoke_id, byte sequence_number, byte proposed_window_size) { buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = (byte)((byte)max_segments | (byte)max_adpu); buffer.buffer[buffer.offset++] = invoke_id; if ((type & BacnetPduTypes.SEGMENTED_MESSAGE) > 0) { buffer.buffer[buffer.offset++] = sequence_number; buffer.buffer[buffer.offset++] = proposed_window_size; } buffer.buffer[buffer.offset++] = (byte)service; }
public static int EncodeComplexAck(EncodeBuffer buffer, BacnetPduTypes type, BacnetConfirmedServices service, byte invoke_id, byte sequence_number, byte proposed_window_number) { int len = 3; buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = invoke_id; if ((type & BacnetPduTypes.SEGMENTED_MESSAGE) > 0) { buffer.buffer[buffer.offset++] = sequence_number; buffer.buffer[buffer.offset++] = proposed_window_number; len += 2; } buffer.buffer[buffer.offset++] = (byte)service; return(len); }
public static void EncodeSimpleAck(EncodeBuffer buffer, BacnetPduTypes type, BacnetConfirmedServices service, byte invoke_id) { buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = invoke_id; buffer.buffer[buffer.offset++] = (byte)service; }
public static void EncodeUnconfirmedServiceRequest(EncodeBuffer buffer, BacnetPduTypes type, BacnetUnconfirmedServices service) { buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = (byte)service; }
/// <summary> /// Also EncodeReject /// </summary> /// <param name="buffer"></param> /// <param name="offset"></param> /// <param name="type"></param> /// <param name="invoke_id"></param> /// <param name="reason"></param> /// <returns></returns> public static void EncodeAbort(EncodeBuffer buffer, BacnetPduTypes type, byte invoke_id, byte reason) { buffer.buffer[buffer.offset++] = (byte)type; buffer.buffer[buffer.offset++] = invoke_id; buffer.buffer[buffer.offset++] = reason; }
public static void Encode(EncodeBuffer buffer, BacnetNpduControls function, BacnetAddress destination, BacnetAddress source, byte hop_count, BacnetNetworkMessageTypes network_msg_type, ushort vendor_id) { // Modif FC bool has_destination = destination != null && destination.net > 0; // && destination.net != 0xFFFF; bool has_source = source != null && source.net > 0 && source.net != 0xFFFF; buffer.buffer[buffer.offset++] = BACNET_PROTOCOL_VERSION; buffer.buffer[buffer.offset++] = (byte)(function | (has_destination ? BacnetNpduControls.DestinationSpecified : 0) | (has_source ? BacnetNpduControls.SourceSpecified : 0)); if (has_destination) { buffer.buffer[buffer.offset++] = (byte)((destination.net & 0xFF00) >> 8); buffer.buffer[buffer.offset++] = (byte)((destination.net & 0x00FF) >> 0); if (destination.net == 0xFFFF) //patch by F. Chaxel { buffer.buffer[buffer.offset++] = 0; } else { buffer.buffer[buffer.offset++] = (byte)destination.adr.Length; if (destination.adr.Length > 0) { for (int i = 0; i < destination.adr.Length; i++) { buffer.buffer[buffer.offset++] = destination.adr[i]; } } } } if (has_source) { buffer.buffer[buffer.offset++] = (byte)((source.net & 0xFF00) >> 8); buffer.buffer[buffer.offset++] = (byte)((source.net & 0x00FF) >> 0); // Modif FC if (destination.net == 0xFFFF) { buffer.buffer[buffer.offset++] = 0; } else { buffer.buffer[buffer.offset++] = (byte)destination.adr.Length; if (destination.adr.Length > 0) { for (int i = 0; i < destination.adr.Length; i++) { buffer.buffer[buffer.offset++] = destination.adr[i]; } } } } if (has_destination) { buffer.buffer[buffer.offset++] = hop_count; } /* * //display warning * if (has_destination || has_source) * { * System.Diagnostics.Trace.TraceWarning("NPDU size is more than 4. This will give an error in the current max_apdu calculation"); * } */ if ((function & BacnetNpduControls.NetworkLayerMessage) > 0) { buffer.buffer[buffer.offset++] = (byte)network_msg_type; if (((byte)network_msg_type) >= 0x80) { buffer.buffer[buffer.offset++] = (byte)((vendor_id & 0xFF00) >> 8); buffer.buffer[buffer.offset++] = (byte)((vendor_id & 0x00FF) >> 0); } } }