object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(GXCommon.LogicalNameToBytes(MBusPortReference)); } if (e.Index == 3) { GXByteBuffer buff = new GXByteBuffer(); buff.SetUInt8((byte)DataType.Array); GXCommon.SetObjectCount(CaptureDefinition.Count, buff); foreach (KeyValuePair <string, string> it in CaptureDefinition) { buff.SetUInt8((byte)DataType.Structure); buff.SetUInt8(2); GXCommon.SetData(settings, buff, DataType.UInt8, it.Key); GXCommon.SetData(settings, buff, DataType.OctetString, ASCIIEncoding.ASCII.GetBytes(it.Value)); } return(buff.Array()); } if (e.Index == 4) { return(CapturePeriod); } if (e.Index == 5) { return(PrimaryAddress); } if (e.Index == 6) { return(IdentificationNumber); } if (e.Index == 7) { return(ManufacturerID); } if (e.Index == 8) { return(DataHeaderVersion); } if (e.Index == 9) { return(DeviceType); } if (e.Index == 10) { return(AccessNumber); } if (e.Index == 11) { return(Status); } if (e.Index == 12) { return(Alarm); } if (Version > 0) { if (e.Index == 13) { return(Configuration); } if (e.Index == 14) { return(EncryptionKeyStatus); } } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(MaxHops); } if (e.Index == 3) { return(WeakLqiValue); } if (e.Index == 4) { return(SecurityLevel); } if (e.Index == 5) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (PrefixTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(PrefixTable.Length, bb); foreach (var it in PrefixTable) { GXCommon.SetData(settings, bb, GXDLMSConverter.GetDLMSDataType(it), it); } } return(bb.Array()); } if (e.Index == 6) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (RoutingConfiguration == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(RoutingConfiguration.Count, bb); foreach (GXDLMSRoutingConfiguration it in RoutingConfiguration) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(14); GXCommon.SetData(settings, bb, DataType.UInt8, it.NetTraversalTime); GXCommon.SetData(settings, bb, DataType.UInt16, it.RoutingTableEntryTtl); GXCommon.SetData(settings, bb, DataType.UInt8, it.Kr); GXCommon.SetData(settings, bb, DataType.UInt8, it.Km); GXCommon.SetData(settings, bb, DataType.UInt8, it.Kc); GXCommon.SetData(settings, bb, DataType.UInt8, it.Kq); GXCommon.SetData(settings, bb, DataType.UInt8, it.Kh); GXCommon.SetData(settings, bb, DataType.UInt8, it.Krt); GXCommon.SetData(settings, bb, DataType.UInt8, it.RreqRetries); GXCommon.SetData(settings, bb, DataType.UInt8, it.RreqRerrWait); GXCommon.SetData(settings, bb, DataType.UInt16, it.BlacklistTableEntryTtl); GXCommon.SetData(settings, bb, DataType.Boolean, it.UnicastRreqGenEnable); GXCommon.SetData(settings, bb, DataType.Boolean, it.RlcEnabled); GXCommon.SetData(settings, bb, DataType.UInt8, it.AddRevLinkCost); } } return(bb.Array()); } if (e.Index == 7) { return(BroadcastLogTableEntryTtl); } if (e.Index == 8) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (RoutingTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(RoutingTable.Count, bb); foreach (GXDLMSRoutingTable it in RoutingTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(6); GXCommon.SetData(settings, bb, DataType.UInt16, it.DestinationAddress); GXCommon.SetData(settings, bb, DataType.UInt16, it.NextHopAddress); GXCommon.SetData(settings, bb, DataType.UInt16, it.RouteCost); GXCommon.SetData(settings, bb, DataType.UInt8, it.HopCount); GXCommon.SetData(settings, bb, DataType.UInt8, it.WeakLinkCount); GXCommon.SetData(settings, bb, DataType.UInt16, it.ValidTime); } } return(bb.Array()); } if (e.Index == 9) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (ContextInformationTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(ContextInformationTable.Count, bb); foreach (GXDLMSContextInformationTable it in ContextInformationTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(5); GXCommon.SetData(settings, bb, DataType.BitString, it.CID); if (it.Context == null) { GXCommon.SetData(settings, bb, DataType.UInt8, 0); } else { GXCommon.SetData(settings, bb, DataType.UInt8, it.Context.Length); } GXCommon.SetData(settings, bb, DataType.OctetString, it.Context); GXCommon.SetData(settings, bb, DataType.Boolean, it.Compression); GXCommon.SetData(settings, bb, DataType.UInt16, it.ValidLifetime); } } return(bb.Array()); } if (e.Index == 10) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (BlacklistTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(BlacklistTable.Count, bb); foreach (var it in BlacklistTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(2); GXCommon.SetData(settings, bb, DataType.UInt16, it.Key); GXCommon.SetData(settings, bb, DataType.UInt16, it.Value); } } return(bb.Array()); } if (e.Index == 11) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (BroadcastLogTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(BroadcastLogTable.Count, bb); foreach (GXDLMSBroadcastLogTable it in BroadcastLogTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(3); GXCommon.SetData(settings, bb, DataType.UInt16, it.SourceAddress); GXCommon.SetData(settings, bb, DataType.UInt8, it.SequenceNumber); GXCommon.SetData(settings, bb, DataType.UInt16, it.ValidTime); } } return(bb.Array()); } if (e.Index == 12) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (GroupTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(GroupTable.Length, bb); foreach (UInt16 it in GroupTable) { GXCommon.SetData(settings, bb, DataType.UInt16, it); } } return(bb.Array()); } if (e.Index == 13) { return(MaxJoinWaitTime); } if (e.Index == 14) { return(PathDiscoveryTime); } if (e.Index == 15) { return(ActiveKeyIndex); } if (e.Index == 16) { return(MetricType); } if (e.Index == 17) { return(CoordShortAddress); } if (e.Index == 18) { return(DisableDefaultRouting); } if (e.Index == 19) { return(DeviceType); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { if (CalendarNameActive == null) { return(null); } if (IsSec()) { return(GXCommon.HexToBytes(CalendarNameActive)); } return(ASCIIEncoding.ASCII.GetBytes(CalendarNameActive)); } if (e.Index == 3) { e.ByteArray = true; bool useOctetString = settings.Standard != Standard.SaudiArabia; return(GetSeasonProfile(settings, SeasonProfileActive, useOctetString)); } if (e.Index == 4) { e.ByteArray = true; return(GetWeekProfileTable(settings, WeekProfileTableActive)); } if (e.Index == 5) { e.ByteArray = true; return(GetDayProfileTable(settings, DayProfileTableActive)); } if (e.Index == 6) { if (CalendarNamePassive == null) { return(null); } if (IsSec()) { return(GXCommon.HexToBytes(CalendarNamePassive)); } return(ASCIIEncoding.ASCII.GetBytes(CalendarNamePassive)); } if (e.Index == 7) { e.ByteArray = true; bool useOctetString = settings.Standard != Standard.SaudiArabia; return(GetSeasonProfile(settings, SeasonProfilePassive, useOctetString)); } if (e.Index == 8) { e.ByteArray = true; return(GetWeekProfileTable(settings, WeekProfileTablePassive)); } if (e.Index == 9) { e.ByteArray = true; return(GetDayProfileTable(settings, DayProfileTablePassive)); } if (e.Index == 10) { return(Time); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(GXCommon.LogicalNameToBytes(DataLinkLayerReference)); } if (e.Index == 3) { return(FromAddressString(IPAddress)); } if (e.Index == 4) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (MulticastIPAddress == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(MulticastIPAddress.Length, data); foreach (string it in MulticastIPAddress) { GXCommon.SetData(settings, data, DataType.UInt32, FromAddressString(it)); } } return(data.Array()); } if (e.Index == 5) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (IPOptions == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(IPOptions.Length, data); foreach (GXDLMSIp4SetupIpOption it in IPOptions) { data.SetUInt8((byte)DataType.Structure); data.SetUInt8(3); GXCommon.SetData(settings, data, DataType.UInt8, it.Type); GXCommon.SetData(settings, data, DataType.UInt8, it.Length); GXCommon.SetData(settings, data, DataType.OctetString, it.Data); } } return(data.Array()); } if (e.Index == 6) { //If subnet mask is not given. return(FromAddressString(SubnetMask)); } if (e.Index == 7) { return(FromAddressString(GatewayIPAddress)); } if (e.Index == 8) { return(this.UseDHCP); } if (e.Index == 9) { return(FromAddressString(PrimaryDNSAddress)); } if (e.Index == 10) { return(FromAddressString(SecondaryDNSAddress)); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); data.SetUInt8((byte)Entries.Count); /*TODO: * foreach (GXScheduleEntry it in Entries) * { * data.SetUInt8((byte)DataType.Structure); * data.SetUInt8(10); * //Add index. * data.SetUInt8((byte)DataType.UInt8); * data.SetUInt8(it.Index); * //Add enable. * data.SetUInt8((byte)DataType.Boolean); * data.SetUInt8((byte) (it.Enable ? 1 : 0)); * * //Add logical Name. * data.SetUInt8((byte)DataType.OctetString); * data.SetUInt8((byte) it.LogicalName.Length); * //TODO: data.SetUInt8((byte)it.LogicalName.Length); * * //Add script selector. * data.SetUInt8((byte)DataType.UInt8); * data.SetUInt8(it.ScriptSelector); * * //Add switch time. * ret = var_setDateTime(&tmp, &se->switchTime); * if (ret != 0) * { * var_clear(&tmp); * break; * } * ret = var_getBytes(&tmp, &value->byteArr); * var_clear(&tmp); * if (ret != 0) * { * break; * } * //Add validity window. * data.SetUInt8((byte)DataType.UInt8); * data.SetUInt8(it.ValidityWindow); * * //Add exec week days. * ba_setUInt8(&value->byteArr, DLMS_DATA_TYPE_BIT_STRING); * setObjectCount(se->execWeekdays.size, &value->byteArr); * ba_addRange(&value->byteArr, se->execWeekdays.data, bit_getByteCount(se->execWeekdays.size)); * * //Add exec spec days. * ba_setUInt8(&value->byteArr, DLMS_DATA_TYPE_BIT_STRING); * setObjectCount(se->execSpecDays.size, &value->byteArr); * ba_addRange(&value->byteArr, se->execSpecDays.data, bit_getByteCount(se->execSpecDays.size)); * * //Add begin date. * ret = var_setDateTime(&tmp, &se->beginDate); * if (ret != 0) * { * var_clear(&tmp); * break; * } * ret = var_getBytes(&tmp, &value->byteArr); * var_clear(&tmp); * if (ret != 0) * { * break; * } * //Add end date. * ret = var_setDateTime(&tmp, &se->endDate); * if (ret != 0) * { * var_clear(&tmp); * break; * } * ret = var_getBytes(&tmp, &value->byteArr); * var_clear(&tmp); * if (ret != 0) * { * break; * } * } * */ return(data.Array()); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(GetObjects(settings, e).Array()); } if (e.Index == 3) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); //Add count data.SetUInt8(2); data.SetUInt8((byte)DataType.Int8); data.SetUInt8(ClientSAP); data.SetUInt8((byte)DataType.UInt16); data.SetUInt16(ServerSAP); return(data.Array()); } if (e.Index == 4) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); //Add count data.SetUInt8(0x7); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.JointIsoCtt); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.Country); GXCommon.SetData(settings, data, DataType.UInt16, ApplicationContextName.CountryName); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.IdentifiedOrganization); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.DlmsUA); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.ApplicationContext); GXCommon.SetData(settings, data, DataType.UInt8, ApplicationContextName.ContextId); return(data.Array()); } if (e.Index == 5) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); data.SetUInt8(6); GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt32((UInt32)XDLMSContextInfo.Conformance); GXCommon.SetData(settings, data, DataType.BitString, bb.SubArray(1, 3)); GXCommon.SetData(settings, data, DataType.UInt16, XDLMSContextInfo.MaxReceivePduSize); GXCommon.SetData(settings, data, DataType.UInt16, XDLMSContextInfo.MaxSendPduSize); GXCommon.SetData(settings, data, DataType.UInt8, XDLMSContextInfo.DlmsVersionNumber); GXCommon.SetData(settings, data, DataType.Int8, XDLMSContextInfo.QualityOfService); GXCommon.SetData(settings, data, DataType.OctetString, XDLMSContextInfo.CypheringInfo); return(data.Array()); } if (e.Index == 6) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); //Add count data.SetUInt8(0x7); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.JointIsoCtt); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.Country); GXCommon.SetData(settings, data, DataType.UInt16, AuthenticationMechanismName.CountryName); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.IdentifiedOrganization); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.DlmsUA); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.AuthenticationMechanismName); GXCommon.SetData(settings, data, DataType.UInt8, AuthenticationMechanismName.MechanismId); return(data.Array()); } if (e.Index == 7) { return(Secret); } if (e.Index == 8) { return(AssociationStatus); } if (e.Index == 9) { return(GXCommon.LogicalNameToBytes(SecuritySetupReference)); } if (e.Index == 10) { return(GetUserList(settings, e).Array()); } if (e.Index == 11) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); //Add structure size. data.SetUInt8(2); GXCommon.SetData(settings, data, DataType.UInt8, CurrentUser.Key); GXCommon.SetData(settings, data, DataType.String, CurrentUser.Value); return(data.Array()); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(ShortAddress); } if (e.Index == 3) { return(RcCoord); } if (e.Index == 4) { return(PANId); } if (e.Index == 5) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (KeyTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(KeyTable.Count, bb); foreach (GXKeyValuePair <byte, byte[]> it in KeyTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(2); GXCommon.SetData(settings, bb, DataType.UInt8, it.Key); GXCommon.SetData(settings, bb, DataType.UInt8, it.Value); } } return(bb.Array()); } if (e.Index == 6) { return(FrameCounter); } if (e.Index == 7) { return(ToneMask); } if (e.Index == 8) { return(TmrTtl); } if (e.Index == 9) { return(MaxFrameRetries); } if (e.Index == 10) { return(NeighbourTableEntryTtl); } if (e.Index == 11) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8((byte)DataType.Array); if (NeighbourTable == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(NeighbourTable.Length, bb); foreach (GXDLMSNeighbourTable it in NeighbourTable) { bb.SetUInt8((byte)DataType.Structure); bb.SetUInt8(11); GXCommon.SetData(settings, bb, DataType.UInt16, it.ShortAddress); GXCommon.SetData(settings, bb, DataType.Boolean, it.Enabled); GXCommon.SetData(settings, bb, DataType.BitString, it.ToneMap); GXCommon.SetData(settings, bb, DataType.Enum, it.Modulation); GXCommon.SetData(settings, bb, DataType.Int8, it.TxGain); GXCommon.SetData(settings, bb, DataType.Enum, it.TxRes); GXCommon.SetData(settings, bb, DataType.BitString, it.TxCoeff); GXCommon.SetData(settings, bb, DataType.UInt8, it.Lqi); GXCommon.SetData(settings, bb, DataType.Int8, it.PhaseDifferential); GXCommon.SetData(settings, bb, DataType.UInt8, it.TMRValidTime); GXCommon.SetData(settings, bb, DataType.UInt8, it.NeighbourValidTime); } } return(bb.Array()); } if (e.Index == 12) { return(HighPriorityWindowSize); } if (e.Index == 13) { return(CscmFairnessLimit); } if (e.Index == 14) { return(BeaconRandomizationWindowLength); } if (e.Index == 15) { return(A); } if (e.Index == 16) { return(K); } if (e.Index == 17) { return(MinCwAttempts); } if (e.Index == 18) { return(CenelecLegacyMode); } if (e.Index == 19) { return(FccLegacyMode); } if (e.Index == 20) { return(MaxBe); } if (e.Index == 21) { return(MaxCsmaBackoffs); } if (e.Index == 22) { return(MinBe); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { GXByteBuffer bb; switch (e.Index) { case 1: return(GXCommon.LogicalNameToBytes(LogicalName)); case 2: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Structure); bb.SetUInt8(2); bb.SetUInt8(DataType.Enum); bb.SetUInt8(AccountStatus); bb.SetUInt8(DataType.Enum); bb.SetUInt8(PaymentMode); return(bb.Array()); case 3: return(CurrentCreditInUse); case 4: return((byte)CurrentCreditStatus); case 5: return(AvailableCredit); case 6: return(AmountToClear); case 7: return(ClearanceThreshold); case 8: return(AggregatedDebt); case 9: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (CreditReferences == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(CreditReferences.Count, bb); foreach (string it in CreditReferences) { bb.SetUInt8(DataType.OctetString); bb.SetUInt8(6); bb.Set(GXCommon.LogicalNameToBytes(it)); } } return(bb.Array()); case 10: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (ChargeReferences == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(ChargeReferences.Count, bb); foreach (string it in ChargeReferences) { bb.SetUInt8(DataType.OctetString); bb.SetUInt8(6); bb.Set(GXCommon.LogicalNameToBytes(it)); } } return(bb.Array()); case 11: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (CreditChargeConfigurations == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(CreditChargeConfigurations.Count, bb); foreach (GXCreditChargeConfiguration it in CreditChargeConfigurations) { bb.SetUInt8(DataType.Structure); bb.SetUInt8(3); bb.SetUInt8(DataType.OctetString); bb.SetUInt8(6); bb.Set(GXCommon.LogicalNameToBytes(it.CreditReference)); bb.SetUInt8(DataType.OctetString); bb.SetUInt8(6); bb.Set(GXCommon.LogicalNameToBytes(it.ChargeReference)); bb.SetUInt8(DataType.BitString); bb.SetUInt8(3); bb.SetUInt8(it.CollectionConfiguration); } } return(bb.Array()); case 12: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (TokenGatewayConfigurations == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(TokenGatewayConfigurations.Count, bb); foreach (GXTokenGatewayConfiguration it in TokenGatewayConfigurations) { bb.SetUInt8(DataType.Structure); bb.SetUInt8(2); bb.SetUInt8(DataType.OctetString); bb.SetUInt8(6); bb.Set(GXCommon.LogicalNameToBytes(it.CreditReference)); bb.SetUInt8(DataType.UInt8); bb.SetUInt8(it.TokenProportion); } } return(bb.Array()); case 13: return(AccountActivationTime); case 14: return(AccountClosureTime); case 15: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Structure); bb.SetUInt8(3); GXCommon.SetData(settings, bb, DataType.StringUTF8, Currency.Name); GXCommon.SetData(settings, bb, DataType.Int8, Currency.Scale); GXCommon.SetData(settings, bb, DataType.Enum, Currency.Unit); return(bb.Array()); case 16: return(LowCreditThreshold); case 17: return(NextCreditAvailableThreshold); case 18: return(MaxProvision); case 19: return(MaxProvisionPeriod); default: e.Error = ErrorCode.ReadWriteDenied; break; } return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return((byte)Mode); } if (e.Index == 3) { return(Repetitions); } if (e.Index == 4) { return(RepetitionDelay); } if (e.Index == 5) { int cnt = CallingWindow.Count; GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); //Add count GXCommon.SetObjectCount(cnt, data); if (cnt != 0) { foreach (var it in CallingWindow) { data.SetUInt8((byte)DataType.Structure); data.SetUInt8((byte)2); //Count GXCommon.SetData(settings, data, DataType.OctetString, it.Key); //start_time GXCommon.SetData(settings, data, DataType.OctetString, it.Value); //end_time } } return(data.Array()); } if (e.Index == 6) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (Destinations == null) { //Add count GXCommon.SetObjectCount(0, data); } else { int cnt = Destinations.Length; //Add count GXCommon.SetObjectCount(cnt, data); foreach (string it in Destinations) { GXCommon.SetData(settings, data, DataType.OctetString, ASCIIEncoding.ASCII.GetBytes(it)); //destination } } return(data.Array()); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { //If client set new value. if (!settings.IsServer && Scaler != 1 && CurrentAverageValue != null) { Type type = null; if (CurrentAverageValue != null) { type = CurrentAverageValue.GetType(); } object tmp; tmp = Convert.ToDouble(CurrentAverageValue) / Scaler; if (type != null) { tmp = Convert.ChangeType(tmp, type); } return(tmp); } return(CurrentAverageValue); } if (e.Index == 3) { //If client set new value. if (!settings.IsServer && Scaler != 1 && LastAverageValue != null) { DataType dt = base.GetDataType(3); if (dt == DataType.None && LastAverageValue != null) { dt = GXCommon.GetDLMSDataType(LastAverageValue.GetType()); } object tmp; tmp = Convert.ToDouble(LastAverageValue) / Scaler; if (dt != DataType.None) { tmp = Convert.ChangeType(tmp, GXCommon.GetDataType(dt)); } return(tmp); } return(LastAverageValue); } if (e.Index == 4) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); data.SetUInt8(2); GXCommon.SetData(settings, data, DataType.Int8, scaler); GXCommon.SetData(settings, data, DataType.Enum, Unit); return(data.Array()); } if (e.Index == 5) { return(Status); } if (e.Index == 6) { return(CaptureTime); } if (e.Index == 7) { return(StartTimeCurrent); } if (e.Index == 8) { return(Period); } if (e.Index == 9) { return(NumberOfPeriods); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { switch (e.Index) { case 1: return GXCommon.LogicalNameToBytes(LogicalName); case 2: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); data.SetUInt8(4); if (ChangedParameter == null) { GXCommon.SetData(settings, data, DataType.UInt16, 0); GXCommon.SetData(settings, data, DataType.OctetString, new byte[] { 0, 0, 0, 0, 0, 0 }); GXCommon.SetData(settings, data, DataType.Int8, 1); GXCommon.SetData(settings, data, DataType.None, null); } else { GXCommon.SetData(settings, data, DataType.UInt16, ChangedParameter.Target.ObjectType); GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(ChangedParameter.Target.LogicalName)); GXCommon.SetData(settings, data, DataType.Int8, ChangedParameter.AttributeIndex); GXCommon.SetData(settings, data, GXDLMSConverter.GetDLMSDataType(ChangedParameter.Value), ChangedParameter.Value); } return data.Array(); } case 3: return CaptureTime; case 4: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (Parameters == null) { data.SetUInt8(0); } else { data.SetUInt8((byte)Parameters.Count); foreach (GXDLMSTarget it in Parameters) { data.SetUInt8((byte)DataType.Structure); data.SetUInt8((byte)3); GXCommon.SetData(settings, data, DataType.UInt16, it.Target.ObjectType); GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(it.Target.LogicalName)); GXCommon.SetData(settings, data, DataType.Int8, it.AttributeIndex); } } return data.Array(); } default: e.Error = ErrorCode.ReadWriteDenied; break; } return null; }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } else if (e.Index == 2) { return(InitiatorElectricalPhase); } else if (e.Index == 3) { return(DeltaElectricalPhase); } else if (e.Index == 4) { return(MaxReceivingGain); } else if (e.Index == 5) { return(MaxTransmittingGain); } else if (e.Index == 6) { return(SearchInitiatorThreshold); } else if (e.Index == 7) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8(DataType.Structure); bb.SetUInt8(2); GXCommon.SetData(settings, bb, DataType.UInt32, MarkFrequency); GXCommon.SetData(settings, bb, DataType.UInt32, SpaceFrequency); return(bb.Array()); } else if (e.Index == 8) { return(MacAddress); } else if (e.Index == 9) { GXByteBuffer bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (MacGroupAddresses == null) { bb.SetUInt8(0); } else { GXCommon.SetObjectCount(MacGroupAddresses.Length, bb); foreach (UInt16 it in MacGroupAddresses) { GXCommon.SetData(settings, bb, DataType.UInt16, it); } } return(bb.Array()); } else if (e.Index == 10) { return(Repeater); } else if (e.Index == 11) { return(RepeaterStatus); } else if (e.Index == 12) { return(MinDeltaCredit); } else if (e.Index == 13) { return(InitiatorMacAddress); } else if (e.Index == 14) { return(SynchronizationLocked); } else if (e.Index == 15) { return(TransmissionSpeed); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { GXByteBuffer bb; switch (e.Index) { case 1: return(GXCommon.LogicalNameToBytes(LogicalName)); case 2: if (string.IsNullOrEmpty(Operator)) { return(null); } return(ASCIIEncoding.ASCII.GetBytes(Operator)); case 3: return(Status); case 4: return(CircuitSwitchStatus); case 5: return(PacketSwitchStatus); case 6: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Structure); if (Version == 0) { bb.SetUInt8(4); GXCommon.SetData(settings, bb, DataType.UInt16, CellInfo.CellId); } else { bb.SetUInt8(7); GXCommon.SetData(settings, bb, DataType.UInt32, CellInfo.CellId); } GXCommon.SetData(settings, bb, DataType.UInt16, CellInfo.LocationId); GXCommon.SetData(settings, bb, DataType.UInt8, CellInfo.SignalQuality); GXCommon.SetData(settings, bb, DataType.UInt8, CellInfo.Ber); if (Version > 0) { GXCommon.SetData(settings, bb, DataType.UInt16, CellInfo.MobileCountryCode); GXCommon.SetData(settings, bb, DataType.UInt16, CellInfo.MobileNetworkCode); GXCommon.SetData(settings, bb, DataType.UInt32, CellInfo.ChannelNumber); } return(bb.Array()); case 7: bb = new GXByteBuffer(); bb.SetUInt8(DataType.Array); if (AdjacentCells == null) { bb.SetUInt8(0); } else { bb.SetUInt8((byte)AdjacentCells.Count); } foreach (AdjacentCell it in AdjacentCells) { bb.SetUInt8(DataType.Structure); bb.SetUInt8(2); GXCommon.SetData(settings, bb, Version == 0 ? DataType.UInt16 : DataType.UInt32, it.CellId); GXCommon.SetData(settings, bb, DataType.UInt8, it.SignalQuality); } return(bb.Array()); case 8: return(CaptureTime); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { return(GXCommon.LogicalNameToBytes(DataLinkLayerReference)); } if (e.Index == 3) { return(AddressConfigMode); } if (e.Index == 4) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (UnicastIPAddress == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(UnicastIPAddress.Length, data); foreach (IPAddress it in UnicastIPAddress) { GXCommon.SetData(settings, data, DataType.OctetString, it.GetAddressBytes()); } } return(data.Array()); } if (e.Index == 5) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (MulticastIPAddress == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(MulticastIPAddress.Length, data); foreach (IPAddress it in MulticastIPAddress) { GXCommon.SetData(settings, data, DataType.OctetString, it.GetAddressBytes()); } } return(data.Array()); } if (e.Index == 6) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (GatewayIPAddress == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(GatewayIPAddress.Length, data); foreach (IPAddress it in GatewayIPAddress) { GXCommon.SetData(settings, data, DataType.OctetString, it.GetAddressBytes()); } } return(data.Array()); } if (e.Index == 7) { if (PrimaryDNSAddress == null) { return(null); } return(PrimaryDNSAddress.GetAddressBytes()); } if (e.Index == 8) { if (SecondaryDNSAddress == null) { return(null); } return(SecondaryDNSAddress.GetAddressBytes()); } if (e.Index == 9) { return(TrafficClass); } if (e.Index == 10) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (NeighborDiscoverySetup == null) { //Object count is zero. data.SetUInt8(0); } else { GXCommon.SetObjectCount(NeighborDiscoverySetup.Length, data); foreach (GXNeighborDiscoverySetup it in NeighborDiscoverySetup) { data.SetUInt8((byte)DataType.Structure); data.SetUInt8(3); GXCommon.SetData(settings, data, DataType.UInt8, it.MaxRetry); GXCommon.SetData(settings, data, DataType.UInt16, it.RetryWaitTime); GXCommon.SetData(settings, data, DataType.UInt32, it.SendPeriod); } } return(data.Array()); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { return(GXCommon.LogicalNameToBytes(LogicalName)); } if (e.Index == 2) { if (APN != null) { return(ASCIIEncoding.ASCII.GetBytes(APN)); } return(null); } if (e.Index == 3) { return(PINCode); } if (e.Index == 4) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Structure); //Add count data.SetUInt8((byte)2); data.SetUInt8((byte)DataType.Structure); data.SetUInt8((byte)5); if (DefaultQualityOfService != null) { GXCommon.SetData(settings, data, DataType.UInt8, DefaultQualityOfService.Precedence); GXCommon.SetData(settings, data, DataType.UInt8, DefaultQualityOfService.Delay); GXCommon.SetData(settings, data, DataType.UInt8, DefaultQualityOfService.Reliability); GXCommon.SetData(settings, data, DataType.UInt8, DefaultQualityOfService.PeakThroughput); GXCommon.SetData(settings, data, DataType.UInt8, DefaultQualityOfService.MeanThroughput); } else { GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); } data.SetUInt8((byte)DataType.Structure); data.SetUInt8((byte)5); if (RequestedQualityOfService != null) { GXCommon.SetData(settings, data, DataType.UInt8, RequestedQualityOfService.Precedence); GXCommon.SetData(settings, data, DataType.UInt8, RequestedQualityOfService.Delay); GXCommon.SetData(settings, data, DataType.UInt8, RequestedQualityOfService.Reliability); GXCommon.SetData(settings, data, DataType.UInt8, RequestedQualityOfService.PeakThroughput); GXCommon.SetData(settings, data, DataType.UInt8, RequestedQualityOfService.MeanThroughput); } else { GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); GXCommon.SetData(settings, data, DataType.UInt8, 0); } return(data.Array()); } e.Error = ErrorCode.ReadWriteDenied; return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { object ret; switch (e.Index) { case 1: ret = GXCommon.LogicalNameToBytes(LogicalName); break; case 2: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (Actions == null) { GXCommon.SetObjectCount(0, data); } else { GXCommon.SetObjectCount(Actions.Length, data); foreach (GXDLMSActionItem it in Actions) { data.SetUInt8((byte)DataType.Structure); //Count data.SetUInt8((byte)2); GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(it.LogicalName)); GXCommon.SetData(settings, data, DataType.UInt16, it.ScriptSelector); } } ret = data.Array(); } break; case 3: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (PermissionsTable == null) { GXCommon.SetObjectCount(0, data); } else { GXCommon.SetObjectCount(PermissionsTable.Length, data); foreach (string it in PermissionsTable) { GXCommon.SetData(settings, data, DataType.BitString, it); } } ret = data.Array(); } break; case 4: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (WeightingsTable == null) { GXCommon.SetObjectCount(0, data); } else { GXCommon.SetObjectCount(WeightingsTable.Length, data); foreach (UInt16[] it in WeightingsTable) { data.SetUInt8((byte)DataType.Array); GXCommon.SetObjectCount(it.Length, data); foreach (UInt16 it2 in it) { GXCommon.SetData(settings, data, DataType.UInt16, it2); } } } ret = data.Array(); } break; case 5: { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8((byte)DataType.Array); if (MostRecentRequestsTable == null) { GXCommon.SetObjectCount(0, data); } else { GXCommon.SetObjectCount(MostRecentRequestsTable.Length, data); foreach (string it in MostRecentRequestsTable) { GXCommon.SetData(settings, data, DataType.BitString, it); } } ret = data.Array(); } break; case 6: ret = LastOutcome; break; default: ret = null; e.Error = ErrorCode.ReadWriteDenied; break; } return(ret); }