GetValues() public method

Returns attributes as an array.
public GetValues ( ) : object[]
return object[]
Exemplo n.º 1
26
 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);
     }            
 }
Exemplo n.º 2
0
 /// <summary>
 /// Get Value from byte array received from the meter.
 /// </summary>
 public object UpdateValue(byte[] data, GXDLMSObject target, int attributeIndex)
 {
     target.SetValue(attributeIndex, GetValue(data, target, attributeIndex));
     return target.GetValues()[attributeIndex - 1];
 }
Exemplo n.º 3
0
 private byte[] GetValue(object name, GXDLMSObject item, int index, int selector, object parameters)
 {
     IGXDLMSBase tmp = item as IGXDLMSBase;
     object value = null;             
     if (tmp != null)
     {
         value = tmp.GetValue(index, selector, parameters);
     }
     else
     {
         object[] values = item.GetValues();
         if (index <= values.Length)
         {
             value = values[index - 1];
         }
     }
     Gurux.DLMS.DataType tp = item.GetDataType(index);
     if (tp == DataType.None)
     {
         tp = Gurux.DLMS.Internal.GXCommon.GetValueType(value);
     }
     //If data is shown as string, but it's OCTECT String.
     if (tp == DataType.OctetString && value is string && item.GetUIDataType(index) == DataType.String)
     {
         value = ASCIIEncoding.ASCII.GetBytes((string)value);
     }
     if (tp != DataType.None || (value == null && tp == DataType.None))
     {
         SendData.AddRange(ReadReply(name, item.ObjectType, index, value, tp));
         return SendData[FrameIndex];
     }
     //Return HW error.
     throw new ArgumentOutOfRangeException();
 }
Exemplo n.º 4
0
 void UpdateValue(GXDLMSObject sender, int index, ListViewItem lv)
 {
     if (index != 1)
     {
         object value = sender.GetValues()[index - 1];
         string str;
         if (value != null && value.GetType().IsArray)
         {
             str = Convert.ToString(GXDLMS.Common.GXHelpers.ConvertFromDLMS(value, DataType.None, DataType.None, true));
         }
         else
         {
             str = GXHelpers.ConvertDLMS2String(value);
         }
         lv.SubItems[index].Text = str;
     }
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 private byte[] GetValue(object name, GXDLMSObject item, int index)
 {            
     object[] values = item.GetValues();
     if (index <= values.Length)
     {
         object value = values[index - 1];
         Gurux.DLMS.DataType tp = item.GetDataType(index);
         if (tp == DataType.None)
         {
             tp = Gurux.DLMS.Internal.GXCommon.GetValueType(value);
         }
         if (tp != DataType.None || (value == null && tp == DataType.None))
         {
             SendData.AddRange(ReadReply(name, item.ObjectType, index, value, tp));
             return SendData[FrameIndex];
         }
     }
     //Return HW error.
     SendData.Add(ServerReportError(1, 5, 3));
     return SendData[FrameIndex];
 }