public void OnValueChanged(GXDLMSViewArguments arg) { if (arg.Index == 2) { if (arg.Value is byte[] && (arg.Value as byte[]).Length == 6) { GXBitString bs = new GXBitString(GXBitString.ToBitString((byte[])arg.Value, 0, 16)); int val = Convert.ToUInt16(bs); ValuesLb.ItemCheck -= ValuesLb_ItemCheck; for (int pos = 0; pos != 16; ++pos) { ValuesLb.SetItemChecked(pos, bs.Value[pos] == '1'); } ValuesLb.ItemCheck += ValuesLb_ItemCheck; GXByteBuffer bb = new GXByteBuffer((byte[])arg.Value); bb.Position = 2; DurationTb.Text = bb.GetUInt32().ToString(); HexTb.Text = bb.ToString(); } else { DurationTb.Text = HexTb.Text = ""; ValuesLb.ItemCheck -= ValuesLb_ItemCheck; for (int pos = 0; pos != 16; ++pos) { ValuesLb.SetItemChecked(pos, false); } ValuesLb.ItemCheck += ValuesLb_ItemCheck; } } else { throw new IndexOutOfRangeException("index"); } }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { switch (e.Index) { case 1: return(GXCommon.LogicalNameToBytes(LogicalName)); case 2: return(TotalAmountPaid); case 3: return(ChargeType); case 4: return(Priority); case 5: return(GetUnitCharge(settings, UnitChargeActive)); case 6: return(GetUnitCharge(settings, UnitChargePassive)); case 7: return(UnitChargeActivationTime); case 8: return(Period); case 9: return(GXBitString.ToBitString((UInt32)ChargeConfiguration, 2)); case 10: return(LastCollectionTime); case 11: return(LastCollectionAmount); case 12: return(TotalAmountRemaining); case 13: return(Proportion); default: e.Error = ErrorCode.ReadWriteDenied; break; } return(null); }
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e) { switch (e.Index) { case 1: return(GXCommon.LogicalNameToBytes(LogicalName)); case 2: return(CurrentCreditAmount); case 3: return(Type); case 4: return(Priority); case 5: return(WarningThreshold); case 6: return(Limit); case 7: return(GXBitString.ToBitString((byte)CreditConfiguration, 5)); case 8: return(Status); case 9: return(PresetCreditAmount); case 10: return(CreditAvailableThreshold); case 11: return(Period); default: e.Error = ErrorCode.ReadWriteDenied; break; } return(null); }
private void AddEntry(GXDLMSSettings settings, GXScheduleEntry it, GXByteBuffer data) { data.SetUInt8((byte)DataType.Structure); data.SetUInt8(10); //Add index. data.SetUInt8((byte)DataType.UInt16); data.SetUInt16(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(6); if (it.Script == null) { data.Set(new byte[] { 0, 0, 0, 0, 0, 0 }); } else { data.Set(GXCommon.LogicalNameToBytes(it.Script.LogicalName)); } //Add script selector. data.SetUInt8((byte)DataType.UInt16); data.SetUInt16(it.ScriptSelector); //Add switch time. GXCommon.SetData(settings, data, DataType.OctetString, it.SwitchTime); //Add validity window. data.SetUInt8((byte)DataType.UInt16); data.SetUInt16(it.ValidityWindow); //Add exec week days. GXCommon.SetData(settings, data, DataType.BitString, GXBitString.ToBitString((byte)it.ExecWeekdays, 7)); //Add exec spec days. GXCommon.SetData(settings, data, DataType.BitString, it.ExecSpecDays); //Add begin date. GXCommon.SetData(settings, data, DataType.OctetString, it.BeginDate); //Add end date. GXCommon.SetData(settings, data, DataType.OctetString, it.EndDate); }
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(PaymentMode); bb.SetUInt8(DataType.Enum); bb.SetUInt8(AccountStatus); return(bb.Array()); case 3: return(CurrentCreditInUse); case 4: return(GXBitString.ToBitString((UInt32)CurrentCreditStatus, 8)); 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)); GXCommon.SetData(null, bb, DataType.BitString, GXBitString.ToBitString((UInt32)it.CollectionConfiguration, 3)); } } 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); }