public void Encode(EncodeBuffer buffer) { ASN1.encode_opening_tag(buffer, 1); ASN1.encode_application_unsigned(buffer, net); ASN1.encode_application_octet_string(buffer, adr, 0, adr.Length); ASN1.encode_closing_tag(buffer, 1); }
private void WriteEffectivePeriod() { // Manual ASN.1/BER encoding EncodeBuffer b = comm.GetEncodeBuffer(0); ASN1.encode_opening_tag(b, 3); DateTime dt; if (TxtStartDate.Text != "Always") { dt = Convert.ToDateTime(TxtStartDate.Text); } else { dt = new DateTime(0); } ASN1.encode_application_date(b, dt); if (TxtEndDate.Text != "Always") { dt = Convert.ToDateTime(TxtEndDate.Text); } else { dt = new DateTime(0); } ASN1.encode_application_date(b, dt); ASN1.encode_closing_tag(b, 3); Array.Resize <byte>(ref b.buffer, b.offset); byte[] InOutBuffer = b.buffer; comm.RawEncodedDecodedPropertyConfirmedRequest(adr, schedule_id, BacnetPropertyIds.PROP_EFFECTIVE_PERIOD, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, ref InOutBuffer); }
public List <object> Entries; // BacnetDate or BacnetDateRange or BacnetweekNDay public void Encode(EncodeBuffer buffer) { if (Entries == null) { return; } foreach (ASN1.IEncode entry in Entries) { if (entry is BacnetDate) { ASN1.encode_tag(buffer, 0, true, 4); entry.Encode(buffer); } if (entry is BacnetDateRange) { ASN1.encode_opening_tag(buffer, 1); entry.Encode(buffer); ASN1.encode_closing_tag(buffer, 1); } if (entry is BacnetweekNDay) { ASN1.encode_tag(buffer, 2, true, 3); entry.Encode(buffer); } } }
public void Encode(EncodeBuffer buffer) { for (int i = 0; i < 1; i++) { ASN1.encode_opening_tag(buffer, 0); List <ExceptionScheduleArray> loArray = loExceptionScheduleArray[i]; for (int j = 0; j < 1; j++) { var loExceptionScheduleTimeValue = loArray[j]; ASN1.bacapp_encode_application_data(buffer, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_DATE, loArray[j].period)); foreach (var ds in loExceptionScheduleTimeValue.loExceptionScheduleTimeValue) { var loTime = ds[0].dt; var loValue = ds[0].Value; ASN1.bacapp_encode_application_data(buffer, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_TIME, loTime)); ASN1.bacapp_encode_application_data(buffer, new BacnetValue(loValue)); } } ASN1.encode_closing_tag(buffer, 0); } }
// no test here if buffer is to small private void WriteEffectiveWeeklySchedule() { // Write Default Schedule First try { BacnetValue[] bv = new BacnetValue[1]; bv[0] = Property.DeserializeValue(TxtScheduleDefault.Text, ScheduleType); comm.WritePropertyRequest(adr, schedule_id, BacnetPropertyIds.PROP_SCHEDULE_DEFAULT, bv); } catch { } // Manual ASN.1/BER encoding EncodeBuffer b = comm.GetEncodeBuffer(0); ASN1.encode_opening_tag(b, 3); // Monday // Time // Value // Time // Value // Thusday // .... for (int i = 0; i < 7; i++) { ASN1.encode_opening_tag(b, 0); TreeNode T = Schedule.Nodes[i]; foreach (TreeNode entry in T.Nodes) { String[] s = entry.Text.Split('='); BacnetValue bdt = Property.DeserializeValue(s[0], BacnetApplicationTags.BACNET_APPLICATION_TAG_TIME); BacnetValue bval; if (s[1].ToLower().Contains("null")) { bval = new BacnetValue(null); } else { bval = Property.DeserializeValue(s[1], ScheduleType); } ASN1.bacapp_encode_application_data(b, bdt); ASN1.bacapp_encode_application_data(b, bval); } ASN1.encode_closing_tag(b, 0); } ASN1.encode_closing_tag(b, 3); Array.Resize <byte>(ref b.buffer, b.offset); byte[] InOutBuffer = b.buffer; comm.RawEncodedDecodedPropertyConfirmedRequest(adr, schedule_id, BacnetPropertyIds.PROP_WEEKLY_SCHEDULE, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, ref InOutBuffer); }
public void Encode(EncodeBuffer buffer) { ASN1.encode_opening_tag(buffer, 0); if (DaySchedule != null) { foreach (var dayItem in DaySchedule) { dayItem.Encode(buffer); } } ASN1.encode_closing_tag(buffer, 0); }
public void ASN1encode(EncodeBuffer buffer) { for (int i = 0; i < 7; i++) { ASN1.encode_opening_tag(buffer, 0); if (days[i] != null) { List <DaySchedule> dsl = days[i]; foreach (DaySchedule ds in dsl) { ASN1.bacapp_encode_application_data(buffer, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_TIME, ds.dt)); ASN1.bacapp_encode_application_data(buffer, new BacnetValue(ds.Value)); } } ASN1.encode_closing_tag(buffer, 0); } }
public void Encode(EncodeBuffer buffer) { byte periodType; if (Period is BACnetCalendarEntry) { periodType = 0; } else if (Period is BacnetObjectId) { periodType = 1; } else { throw new Exception("BacnetSpecialEvent - unsupported period type -> has to be BacnetCalendarEntry or BacnetObjectId"); } ASN1.encode_opening_tag(buffer, periodType); if (Period is BACnetCalendarEntry) { ((BACnetCalendarEntry)Period).Encode(buffer); ASN1.encode_closing_tag(buffer, 0); } else if (Period is BacnetObjectId) { if (((BacnetObjectId)Period).Type != BacnetObjectTypes.OBJECT_CALENDAR) { throw new Exception("Period Object is not an calendar"); } ASN1.encode_bacnet_object_id(buffer, ((BacnetObjectId)Period).Type, ((BacnetObjectId)Period).Instance); } ASN1.encode_opening_tag(buffer, 2); if (ListOfTimeValues != null) { foreach (var tv in ListOfTimeValues) { tv.Encode(buffer); } } ASN1.encode_closing_tag(buffer, 2); ASN1.encode_context_unsigned(buffer, 3, EventPriority); }
public object Entry; // BacnetDate or BacnetDateRange or BacnetweekNDay public void Encode(EncodeBuffer buffer) { var encEntry = Entry as ASN1.IEncode; if (encEntry is BacnetDate) { ASN1.encode_tag(buffer, 0, true, 4); encEntry.Encode(buffer); } if (encEntry is BacnetDateRange) { ASN1.encode_opening_tag(buffer, 1); encEntry.Encode(buffer); ASN1.encode_closing_tag(buffer, 1); } if (encEntry is BacnetweekNDay) { ASN1.encode_tag(buffer, 2, true, 3); encEntry.Encode(buffer); } }