void UpdateObject(GXDLMSObject it, GXDLMSCategory item)
 {
     item.ShortName = (UInt16)it.ShortName;
     item.LogicalName = it.LogicalName;
     if (it.ShortName != 0)
     {
         item.Name = string.Format("0x{0} {1} {2}", it.ShortName.ToString("X4"), it.LogicalName, it.Description);
     }
     else
     {
         item.Name = it.LogicalName + " " + it.Description;
     }
     //Update description.
     item.Description = it.Description;
     //Update atribute index.
     for (int pos = 2; pos != (it as IGXDLMSBase).GetAttributeCount() + 1; ++pos)
     {
         string name = (it as IGXDLMSBase).GetNames()[pos - 1];
         object value = it.GetValues()[pos - 1];
         GXDLMSProperty prop;
         if (((pos == 2 || pos == 3) && it.ObjectType == ObjectType.DemandRegister) || 
             (pos == 2 && it.ObjectType == ObjectType.ExtendedRegister))
         {
             prop = new GXDLMSRegister();
             prop.ObjectType = it.ObjectType;
             prop.LogicalName = it.LogicalName;
             prop.ShortName = it.ShortName;
             prop.Name = name;
             prop.AttributeOrdinal = pos;
         }
         else
         {
             prop = new GXDLMSProperty(it.ObjectType, it.LogicalName, it.ShortName, name, pos);
         }
         item.Properties.Add(prop);
         prop.DLMSType = it.GetDataType(pos);
         //Update scaler and unit.
         if ((pos == 4 && it.ObjectType == ObjectType.DemandRegister) ||
             (pos == 3 && it.ObjectType == ObjectType.ExtendedRegister))
         {
             prop.ValueType = DataType.String;
         }
         else
         {
             if (value is Enum)
             {
                 prop.ForcePresetValues = true;
                 foreach (object val in Enum.GetValues(value.GetType()))
                 {
                     prop.Values.Add(new GXValueItem(val.ToString(), (int)val));
                 }
             }
             else
             {
                 prop.ValueType = it.GetUIDataType(pos);
                 if (prop.ValueType == DataType.None)
                 {
                     prop.ValueType = it.GetDataType(pos);
                 }
             }
         }
         prop.AccessMode = (Gurux.Device.AccessMode)it.GetAccess(pos);
     }            
 }
 public override void Initialize(object info)
 {
     GXObisCode code = info as GXObisCode;
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Logical Name", 1));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Value", 2));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Status", 4));
     GXDLMSProperty prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Capture Time", 5);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);
 }
 void UpdateClockBaseValueItems(GXDLMSProperty prop)
 {
     prop.Values.Clear();
     prop.Values.Add(new GXValueItem("Not defined", 0x0));
     prop.Values.Add(new GXValueItem("Internal crystal", 1));
     prop.Values.Add(new GXValueItem("mains frequency 50 Hz", 2));
     prop.Values.Add(new GXValueItem("mains frequency 60 Hz", 3));
     prop.Values.Add(new GXValueItem("GPS (global positioning system)", 4));
     prop.Values.Add(new GXValueItem("DCF 77 (Braunschweig time standard)", 5));
     prop.ForcePresetValues = true;
     prop.DefaultValue = "Not defined";            
     prop.AccessMode = Gurux.Device.AccessMode.Read;
 }
 public override void Initialize(object info)
 {
     GXObisCode code = info as GXObisCode;
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Logical Name", 1));
     GXDLMSProperty p = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Communication speed", 2);
     GXDLMSIECOpticalPortSetup.UpdateBaudrates(p);
     this.Properties.Add(p);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Window size in transmit", 3));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Window size in receive", 4));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Maximum info length transmit", 5));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Maximum info length receive", 6));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Inter charachter timeout", 7));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Inactivity timeout", 8));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Device Address", 9));
 }
 void UpdateStatusValueItems(GXDLMSProperty prop)
 {
     prop.Values.Clear();
     prop.Values.Add(new GXValueItem("OK", 0x0));
     prop.Values.Add(new GXValueItem("Invalid value", 0x1));
     prop.Values.Add(new GXValueItem("Doubtful value", 0x2));
     prop.Values.Add(new GXValueItem("Different Clock Base", 0x4));
     prop.Values.Add(new GXValueItem("Reserved 1", 0x8));
     prop.Values.Add(new GXValueItem("Reserved 2", 0x10));
     prop.Values.Add(new GXValueItem("Reserved 3", 0x20));
     prop.Values.Add(new GXValueItem("Reserved 4", 0x40));
     prop.Values.Add(new GXValueItem("Daylight Save Active", 0x80));
     prop.ForcePresetValues = true;
     prop.DefaultValue = "OK";
     prop.AccessMode = Gurux.Device.AccessMode.Read;
 }
 public override void Initialize(object info)
 {
     GXObisCode code = info as GXObisCode;
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Logical Name", 1));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Current Average Value", 2));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Last Average Value", 3));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Status", 5));
     GXDLMSProperty prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Capture Time", 6);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);
     prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Start Time Current", 7);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Period", 8));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Number of Periods", 9));
 }
 public override void Initialize(object info)
 {
     GXObisCode code = info as GXObisCode;
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Logical Name", 1));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Defaultmode", 2));
     GXDLMSProperty p = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Default baudrate", 3);
     UpdateBaudrates(p);
     p.DefaultValue = "300";
     this.Properties.Add(p);
     p = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Maximum baudrate", 4);
     UpdateBaudrates(p);
     p.DefaultValue = "300";
     this.Properties.Add(p);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Responsetime", 5));
     GXDLMSProperty prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Device Address", 6);
     prop.ValueType = typeof(string);
     this.Properties.Add(prop);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Password 1", 7));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Password 2", 8));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Password 5", 9));
 }
 public override void Initialize(object info)
 {
     GXObisCode code = info as GXObisCode;
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Logical Name", 1));
     GXDLMSProperty prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Time", 2);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Time Zone", 3));
     prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Status", 4);
     UpdateStatusValueItems(prop);
     this.Properties.Add(prop);
     prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Daylight Savings begin", 5);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);            
     prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Daylight Savings end", 6);
     prop.ValueType = typeof(DateTime);
     this.Properties.Add(prop);
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Deviation", 7));
     this.Properties.Add(new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Daylight Savings Enabled", 8));
     prop = new GXDLMSProperty(this.ObjectType, this.LogicalName, this.ShortName, "Clock Base", 9);
     UpdateClockBaseValueItems(prop);
     this.Properties.Add(prop);
 }
 /// <summary>
 /// Update categories data.
 /// </summary>
 /// <param name="trace"></param>
 /// <param name="progressbar"></param>
 /// <param name="media"></param>
 /// <param name="Device"></param>
 /// <param name="wt"></param>
 /// <param name="cosem"></param>
 /// <param name="man"></param>
 /// <param name="objs"></param>
 /// <param name="dataItems"></param>
 /// <param name="registers"></param>
 private object UpdateData(Gurux.Common.IGXMedia media, GXDLMSDevice Device, int wt, GXDLMSClient cosem, GXManufacturer man, GXDLMSObject it, GXCategory dataItems, GXCategory registers)
 {
     GXObisCode code = man.ObisCodes.FindByLN(it.ObjectType, it.LogicalName, null);            
     if (it.ObjectType == ObjectType.Register)
     {
         GXDLMSRegister prop = new GXDLMSRegister();
         UpdateObject(it, prop, 2);
         registers.Properties.Add(prop);
         return prop;
     }
     else if (it.ObjectType == Gurux.DLMS.ObjectType.Data)
     {
         GXDLMSProperty prop = new GXDLMSProperty();
         prop.ObjectType = ObjectType.Data;
         UpdateObject(it, prop, 2);
         dataItems.Properties.Add(prop);
         return prop;
     }
     else if (it.ObjectType == Gurux.DLMS.ObjectType.ProfileGeneric)
     {
         GXDLMSProfileGeneric pg = it as GXDLMSProfileGeneric;
         GXDLMSTable table = new GXDLMSTable();
         table.Name = it.LogicalName + " " + it.Description;
         table.ShortName = it.ShortName;
         table.LogicalName = it.LogicalName;
         table.AccessMode = Gurux.Device.AccessMode.Read;
         foreach(var it2 in pg.CaptureObjects)
         {
             GXDLMSProperty prop;
             if (it2.Key is Gurux.DLMS.Objects.GXDLMSRegister)
             {
                 Gurux.DLMS.Objects.GXDLMSRegister tmp = it2.Key as Gurux.DLMS.Objects.GXDLMSRegister;
                 GXDLMSRegister r = new GXDLMSRegister();
                 prop = r;
                 r.Scaler = tmp.Scaler;
                 r.Unit = tmp.Unit.ToString();                    
             }
             else
             {
                 prop = new GXDLMSProperty();
             }
             int index = it2.Value.AttributeIndex;
             prop.Name = it2.Key.LogicalName + " " + it2.Key.Description;
             prop.ObjectType = it2.Key.ObjectType;
             prop.AttributeOrdinal = index;
             prop.LogicalName = it2.Key.LogicalName;
             table.Columns.Add(prop);
             prop.DLMSType = it.GetDataType(index);                    
             prop.ValueType = it2.Key.GetUIDataType(index);
         }
         Device.Tables.Add(table);
         return table; 
     }
     GXDLMSCategory cat = new GXDLMSCategory();
     cat.ObjectType = it.ObjectType;
     UpdateObject(it, cat);
     Device.Categories.Add(cat);
     return cat;            
 }
 void UpdateObject(GXDLMSObject it, GXDLMSProperty item, int index)
 {
     //Update name.
     item.AttributeOrdinal = index;
     item.ShortName = it.ShortName;
     item.LogicalName = it.LogicalName;
     if (it.ShortName != 0)
     {
         item.Name = string.Format("0x{0} {1} {2}", it.ShortName.ToString("X4"), it.LogicalName, it.Description);
     }
     else
     {
         item.Name = it.LogicalName + " " + it.Description;
     }                        
     //Update description.
     item.Description = it.Description;
     //Update access mode.
     item.DLMSType = it.GetDataType(index);
     if (item.DLMSType == DataType.Enum)
     {
         item.ForcePresetValues = true;
         object value = it.GetValues()[index - 1];
         foreach (object val in Enum.GetValues(value.GetType()))
         {
             item.Values.Add(new GXValueItem(val.ToString(), (int)val));
         }
     }
     else
     {
         item.ValueType = it.GetUIDataType(index);                
         if (item.ValueType == DataType.None)
         {
             item.ValueType = it.GetDataType(index);                    
         }
     }
     item.AccessMode = (Gurux.Device.AccessMode)it.GetAccess(index);
 }
 protected static void UpdateBaudrates(GXDLMSProperty prop)
 {
 }
Beispiel #12
0
 void AddColumn(GXDLMSClient cosem, GXManufacturer man, GXDLMSTable table, byte[] ln, object scalar, int index, string name)
 {
     string logicanName = null;            
     if (ln != null)
     {
         logicanName = GXHelpers.ConvertFromDLMS(ln, DataType.OctetString, DataType.OctetString, false).ToString();
         if (string.IsNullOrEmpty(name))
         {
             GXObisCode code = man.ObisCodes.FindByLN(ObjectType.None, logicanName, null);
             if (code != null)
             {
                 name = code.Description;
             }
             else
             {
                 name = logicanName;
             }
         }
     }
     if (scalar == null)
     {
         GXDLMSProperty prop = new GXDLMSProperty(ObjectType.Data, logicanName, 0, name, index, DataType.DateTime);
         prop.ValueType = DataType.DateTime;
         prop.AccessMode = Gurux.Device.AccessMode.Read;
         table.Columns.Add(prop);
     }
     else
     {
         object[] tmp = (object[])scalar;
         Gurux.DLMS.AddIn.GXDLMSRegister prop = new Gurux.DLMS.AddIn.GXDLMSRegister();
         prop.Scaler = Math.Pow(10, Convert.ToInt32(tmp[0]));
         prop.Unit = tmp[1].ToString();
         prop.LogicalName = logicanName;
         prop.Name = name;
         prop.AttributeOrdinal = index;
         prop.DLMSType = DataType.UInt32;
         prop.ValueType = DataType.Float64;
         prop.AccessMode = Gurux.Device.AccessMode.Read;
         table.Columns.Add(prop);
     }
 }