当前位置: 首页>>代码示例>>C#>>正文


C# DLMS.GXDLMSSettings类代码示例

本文整理汇总了C#中Gurux.DLMS.GXDLMSSettings的典型用法代码示例。如果您正苦于以下问题:C# GXDLMSSettings类的具体用法?C# GXDLMSSettings怎么用?C# GXDLMSSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GXDLMSSettings类属于Gurux.DLMS命名空间,在下文中一共展示了GXDLMSSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GXDLMSNotify

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="useLogicalNameReferencing">Is Logical or short name referencing used.</param>
 /// <param name="clientAddress">Client address. Default is 0x10</param>
 /// <param name="ServerAddress">Server ID. Default is 1.</param>
 /// <param name="interfaceType">Interface type. Default is general.</param>
 public GXDLMSNotify(bool useLogicalNameReferencing,
     int clientAddress, int serverAddress, InterfaceType interfaceType)
 {
     Settings = new GXDLMSSettings(true);
     Settings.UseLogicalNameReferencing = useLogicalNameReferencing;
     Settings.InterfaceType = interfaceType;
     Settings.ServerAddress = serverAddress;
     Settings.ClientAddress = clientAddress;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:16,代码来源:GXDLMSNotify.cs

示例2: HandleGetRequest

        public static void HandleGetRequest(GXDLMSSettings settings, GXDLMSServer server, GXByteBuffer data, GXByteBuffer replyData, GXDLMSTranslatorStructure xml)
        {
            //Return error if connection is not established.
            if (xml == null && !settings.Connected)
            {
                replyData.Set(GXDLMSServer.GenerateConfirmedServiceError(ConfirmedServiceError.InitiateError,
                              ServiceError.Service, (byte)Service.Unsupported));
                return;
            }

            GetCommandType type = (GetCommandType)data.GetUInt8();
            // Get invoke ID and priority.
            byte invokeID = data.GetUInt8();
            if (xml != null)
            {
                xml.AppendStartTag(Command.GetRequest);
                xml.AppendStartTag(Command.GetRequest, type);
                xml.AppendLine(TranslatorTags.InvokeId, "Value", xml.IntegerToHex(invokeID, 2));
            }

            // GetRequest normal
            if (type == GetCommandType.Normal)
            {
                GetRequestNormal(settings, server, data, replyData, xml);
            }
            else if (type == GetCommandType.NextDataBlock)
            {
                // Get request for next data block
                GetRequestNextDataBlock(settings, server, data, replyData, xml);
            }
            else if (type == GetCommandType.WithList)
            {
                // Get request with a list.
                GetRequestWithList(settings, server, data, replyData, xml);
            }
            else
            {
                Debug.WriteLine("HandleGetRequest failed. Invalid command type.");
                settings.ResetBlockIndex();
                GXByteBuffer bb = new GXByteBuffer();
                // Access Error : Device reports a hardware fault.
                bb.SetUInt8((byte)ErrorCode.HardwareFault);
                GXDLMS.GetLNPdu(new GXDLMSLNParameters(settings, Command.GetResponse, (byte)type, null, bb, (byte)ErrorCode.Ok), replyData);
            }
            if (xml != null)
            {
                xml.AppendEndTag(Command.GetRequest, type);
                xml.AppendEndTag(Command.GetRequest);
            }
        }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:50,代码来源:GXDLMSLNCommandHandlers.cs

示例3: GetInvokeIDPriority

 /// <summary>
 /// Generates Invoke ID and priority.
 /// </summary>
 /// <param name="settings">DLMS settings.</param>
 /// <returns>Invoke ID and priority.</returns>
 static byte GetInvokeIDPriority(GXDLMSSettings settings)
 {
     byte value = 0;
     if (settings.Priority == Priority.High)
     {
         value = 0x80;
     }
     if (settings.ServiceClass == ServiceClass.Confirmed)
     {
         value |= 0x40;
     }
     value |= (byte)(settings.InvokeID & 0xF);
     return value;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:19,代码来源:GXDLMS.cs

示例4: GetLongInvokeIDPriority

 /// <summary>
 /// Generates Invoke ID and priority.
 /// </summary>
 /// <param name="settings">DLMS settings.</param>
 /// <returns>Invoke ID and priority.</returns>
 static UInt32 GetLongInvokeIDPriority(GXDLMSSettings settings)
 {
     UInt32 value = 0;
     if (settings.Priority == Priority.High)
     {
         value = 0x80000000;
     }
     if (settings.ServiceClass == ServiceClass.Confirmed)
     {
         value |= 0x40000000;
     }
     value |= (UInt32)(settings.longInvokeID & 0xFFFFFF);
     ++settings.longInvokeID;
     return value;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:20,代码来源:GXDLMS.cs

示例5: GXByteBuffer

 object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         return this.LogicalName;
     }
     if (e.Index == 2)
     {
         return MBusPortReference;
     }
     if (e.Index == 3)
     {
         GXByteBuffer buff = new GXByteBuffer();
         buff.Add((byte)DataType.Array);
         GXCommon.SetObjectCount(CaptureDefinition.Count, buff);
         foreach (KeyValuePair<string, string> it in CaptureDefinition)
         {
             buff.Add((byte)DataType.Structure);
             buff.Add(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;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:74,代码来源:GXDLMSMBusClient.cs

示例6: if

 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         if (e.Value is string)
         {
             PHYReference = e.Value.ToString();
         }
         else
         {
             PHYReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 3)
     {
         List<GXDLMSPppSetupLcpOption> items = new List<GXDLMSPppSetupLcpOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupLcpOption it = new GXDLMSPppSetupLcpOption();
                 it.Type = (PppSetupLcpOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         LCPOptions = items.ToArray();
     }
     else if (e.Index == 4)
     {
         List<GXDLMSPppSetupIPCPOption> items = new List<GXDLMSPppSetupIPCPOption>();
         if (e.Value is Object[])
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDLMSPppSetupIPCPOption it = new GXDLMSPppSetupIPCPOption();
                 it.Type = (PppSetupIPCPOptionType)Convert.ToByte(item[0]);
                 it.Length = Convert.ToByte(item[1]);
                 it.Data = item[2];
                 items.Add(it);
             }
         }
         IPCPOptions = items.ToArray();
     }
     else if (e.Index == 5)
     {
         UserName = (byte[])((Object[])e.Value)[0];
         Password = (byte[])((Object[])e.Value)[1];
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:66,代码来源:GXDLMSPppSetup.cs

示例7: if

 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         PlcInactivityTimeout = (byte)e.Value;
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:22,代码来源:GXDLMSIEC14908PhysicalSetup.cs

示例8: if

 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         if (Scaler != 1)
         {
             try
             {
                 CurrentAverageValue = Convert.ToDouble(e.Value) * Scaler;
             }
             catch (Exception)
             {
                 //Sometimes scaler is set for wrong Object type.
                 CurrentAverageValue = e.Value;
             }
         }
         else
         {
             CurrentAverageValue = e.Value;
         }
     }
     else if (e.Index == 3)
     {
         if (Scaler != 1)
         {
             try
             {
                 LastAverageValue = Convert.ToDouble(e.Value) * Scaler;
             }
             catch (Exception)
             {
                 //Sometimes scaler is set for wrong Object type.
                 LastAverageValue = e.Value;
             }
         }
         else
         {
             LastAverageValue = e.Value;
         }
     }
     else if (e.Index == 4)
     {
         if (e.Value == null)
         {
             Scaler = 1;
             Unit = Unit.None;
         }
         else
         {
             object[] arr = (object[])e.Value;
             if (arr.Length != 2)
             {
                 throw new Exception("setValue failed. Invalid scaler unit value.");
             }
             _scaler = Convert.ToInt32(arr[0]);
             Unit = (Unit)Convert.ToInt32(arr[1]);
         }
     }
     else if (e.Index == 5)
     {
         Status = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 6)
     {
         if (e.Value == null)
         {
             CaptureTime = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime);
             }
             CaptureTime = (GXDateTime)e.Value;
         }
     }
     else if (e.Index == 7)
     {
         if (e.Value == null)
         {
             StartTimeCurrent = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime);
             }
//.........这里部分代码省略.........
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:101,代码来源:GXDLMSDemandRegister.cs

示例9: if

 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         Mode = (AutoConnectMode)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         Repetitions = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         RepetitionDelay = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         CallingWindow.Clear();
         if (e.Value != null)
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime);
                 GXDateTime end = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 CallingWindow.Add(new KeyValuePair<GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 6)
     {
         Destinations = null;
         if (e.Value != null)
         {
             List<string> items = new List<string>();
             foreach (byte[] item in (object[])e.Value)
             {
                 string it = GXDLMSClient.ChangeType(item, DataType.String).ToString();
                 items.Add(it);
             }
             Destinations = items.ToArray();
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:57,代码来源:GXDLMSAutoConnect.cs

示例10: GXByteBuffer

 object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         return this.LogicalName;
     }
     if (e.Index == 2)
     {
         return Value;
     }
     if (e.Index == 3)
     {
         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();
     }
     e.Error = ErrorCode.ReadWriteDenied;
     return null;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:22,代码来源:GXDLMSRegister.cs

示例11: GXByteBuffer

 object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         return this.LogicalName;
     }
     if (e.Index == 2)
     {
         int cnt = 0;
         if (SapAssignmentList != null)
         {
             cnt = SapAssignmentList.Count;
         }
         GXByteBuffer data = new GXByteBuffer();
         data.SetUInt8((byte)DataType.Array);
         //Add count
         GXCommon.SetObjectCount(cnt, data);
         if (cnt != 0)
         {
             foreach (var it in SapAssignmentList)
             {
                 data.SetUInt8((byte)DataType.Structure);
                 data.SetUInt8((byte)2); //Count
                 GXCommon.SetData(settings, data, DataType.UInt16, it.Key);
                 GXCommon.SetData(settings, data, DataType.OctetString, ASCIIEncoding.ASCII.GetBytes(it.Value));
             }
         }
         return data.Array();
     }
     e.Error = ErrorCode.ReadWriteDenied;
     return null;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:32,代码来源:GXDLMSSapAssignment.cs

示例12: if

 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         SecurityPolicy = (SecurityPolicy)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         SecuritySuite = (SecuritySuite)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         ClientSystemTitle = (byte[])e.Value;
     }
     else if (e.Index == 5)
     {
         ServerSystemTitle = (byte[])e.Value;
     }
     else if (e.Index == 6)
     {
         UpdateSertificates((object[])e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:38,代码来源:GXDLMSSecuritySetup.cs

示例13: AddData

 /// <summary>
 /// Add value of COSEM object to byte buffer.
 /// </summary>
 /// <param name="obj">COSEM object.</param>
 /// <param name="index">Attribute index.</param>
 /// <param name="buff">Byte buffer.</param>
 /// <remarks>
 /// AddData method can be used with GetDataNotificationMessage -method.
 /// DLMS spesification do not specify the structure of Data-Notification body.
 /// So each manufacture can sent different data.
 /// </remarks>
 /// <seealso cref="GetDataNotificationMessages"/>
 internal static void AddData(GXDLMSSettings settings, GXDLMSObject obj, int index, GXByteBuffer buff)
 {
     DataType dt;
     object value = (obj as IGXDLMSBase).GetValue(settings, new ValueEventArgs(settings, obj, index, 0, null));
     dt = obj.GetDataType(index);
     if (dt == DataType.None && value != null)
     {
         dt = GXCommon.GetValueType(value);
     }
     GXCommon.SetData(settings, buff, dt, value);
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:23,代码来源:GXDLMSNotify.cs

示例14: GetSertificates

 object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         return this.LogicalName;
     }
     if (e.Index == 2)
     {
         return SecurityPolicy;
     }
     if (e.Index == 3)
     {
         return SecuritySuite;
     }
     if (this.Version > 0)
     {
         if (e.Index == 4)
         {
             return ClientSystemTitle;
         }
         if (e.Index == 5)
         {
             return ServerSystemTitle;
         }
         if (e.Index == 6)
         {
             return GetSertificates();
         }
     }
     e.Error = ErrorCode.ReadWriteDenied;
     return null;
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:32,代码来源:GXDLMSSecuritySetup.cs

示例15: foreach

 byte[] IGXDLMSBase.Invoke(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 2)
     {
         foreach (object tmp in e.Parameters as object[])
         {
             object[] item = tmp as object[];
             GlobalKeyType type = (GlobalKeyType)Convert.ToInt32(item[0]);
             byte[] data = (byte[])item[1];
             switch (type)
             {
                 case GlobalKeyType.UnicastEncryption:
                 case GlobalKeyType.BroadcastEncryption:
                     //Invalid type
                     e.Error = ErrorCode.ReadWriteDenied;
                     break;
                 case GlobalKeyType.Authentication:
                     //if settings.Cipher is null non secure server is used.
                     settings.Cipher.AuthenticationKey = GXDLMSSecureClient.Decrypt(settings.Kek, data);
                     break;
                 case GlobalKeyType.Kek:
                     settings.Kek = GXDLMSSecureClient.Decrypt(settings.Kek, data);
                     break;
                 default:
                     //Invalid type
                     e.Error = ErrorCode.ReadWriteDenied;
                     break;
             }
         }
         //Return standard reply.
         return null;
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
         return null;
     }
 }
开发者ID:Gurux,项目名称:Gurux.DLMS.Net,代码行数:38,代码来源:GXDLMSSecuritySetup.cs


注:本文中的Gurux.DLMS.GXDLMSSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。