/// <summary> /// Fill Read Service Data /// </summary> /// <param name="itemId"></param> /// <param name="hasReadRights"></param> /// <param name="itemValues"></param> /// <returns></returns> private Helper.CustomProperties FillReadService(string itemId, bool hasReadRights, ValueQT itemValues) { //display the read values Helper.CustomProperties readServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Item Id", "System.String", null, null, itemId); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); if (hasReadRights && itemValues != null) { customProperty = new DemoClient.Helper.CustomProperty("Value", "System.String", null, null, ValueConverter.ArrayToString(itemValues)); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Quality", "System.String", null, null, itemValues.Quality.ToString()); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Time Stamp", "System.String", null, null, ValueConverter.DateTimeOptions(itemValues.TimeStamp)); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); } else { //there are no read values, fiil data with empty strings customProperty = new DemoClient.Helper.CustomProperty("Value", "System.String", null, null, ""); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Quality", "System.String", null, null, ""); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Time Stamp", "System.String", null, null, ""); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; readServiceColl.Properties.Add(customProperty); } return(readServiceColl); }
/// <summary> /// Fill Empty Data /// </summary> /// <param name="itemId"></param> private Helper.CustomProperties FillEmptyValueQT(string itemId, Type itemDataType) { Helper.DataTypes dataTypeHelper = new DataTypes(); Helper.CustomProperties writeServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Item Id", "System.String", null, null, itemId); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; writeServiceColl.Properties.Add(customProperty); //the DaItem VALUE is not an array customProperty = new DemoClient.Helper.CustomProperty("Value", "System.String", null, null, ""); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; writeServiceColl.Properties.Add(customProperty); if (itemDataType == null) { customProperty = new DemoClient.Helper.CustomProperty("Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), null, null, "", typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); } else { dataTypeHelper.Type = itemDataType; customProperty = new DemoClient.Helper.CustomProperty("Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), null, null, dataTypeHelper.NativeDataType, typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); } customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; writeServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Start Index", "System.String", null, null, ""); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; writeServiceColl.Properties.Add(customProperty); return(writeServiceColl); }
/// <summary> /// AeSubscription Properties /// </summary> /// <param name="subscription"></param> internal bool AeSubscription(AeSubscription subscription) { panelBottom.Visible = true; this.daItem = null; aeSubscription = subscription; daSession = null; daSubscription = null; aeSession = null; Helper.DataTypes dataTypeHelper = new DataTypes(); this.panelBottom.Visible = true; //AeSubscription Buffer Time Helper.CustomProperties propServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Buffer Time", "System.String", "General", null, aeSubscription.RequestedBufferTime); propServiceColl.Properties.Add(customProperty); //AeSubscription Revised Buffer Time customProperty = new DemoClient.Helper.CustomProperty("Revised Buffer Time", "System.String", "General", null, aeSubscription.RevisedBufferTime); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSubscription Max Size customProperty = new DemoClient.Helper.CustomProperty("Max Size", "System.String", "General", null, aeSubscription.RequestedMaxSize); propServiceColl.Properties.Add(customProperty); //AeSubscription Revised Max Size customProperty = new DemoClient.Helper.CustomProperty("Revised Max Size", "System.String", "General", null, aeSubscription.RevisedMaxSize); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); this.propertyGrid.PropertySort = PropertySort.Categorized; this.propertyGrid.SelectedObject = propServiceColl; return(true); }
/// <summary> /// Set DaProperty data /// </summary> /// <param name="propertiesColl"></param> /// <param name="property"></param> /// <param name="category"></param> private void SetPropertyData(ref Helper.CustomProperties propertiesColl, DaProperty property, string category) { Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Item Id", "System.String", category, null, property.ItemId); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Property Id", "System.String", category, null, property.Id); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Property Name", "System.String", category, null, property.Name); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Value", "System.Object", category, null, property.ValueQT.Data); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Data Type", "System.String", category, null, property.DataType); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Description", "System.String", category, null, property.Description); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propertiesColl.Properties.Add(customProperty); }
/// <summary> /// Adds a CustomProperty to the end of the CustomPropertyCollection. /// </summary> /// <param name="value"></param> /// <returns></returns> public int Add(CustomProperty value) { int index = innerArray.Add(value); return(index); }
public CustomPropertyDescriptor(CustomProperty item, CustomProperties items, string name, Attribute[] attrs) : base(name, attrs) { this.customProperties = items; this.customProperty = item; }
/// <summary> /// Removes the first occurrence of a specific object from the CustomPropertyCollection. /// </summary> /// <param name="obj"></param> public void Remove(CustomProperty obj) { innerArray.Remove(obj); }
/// <summary> /// Inserts a CustomProperty object into the CustomPropertyCollection at the specified index. /// </summary> /// <param name="index"></param> /// <param name="value"></param> public void Insert(int index, CustomProperty value) { innerArray.Insert(index, value); }
/// <summary> /// Searches for the specified CustomProperty /// </summary> /// <param name="value"></param> /// <returns></returns> public int IndexOf(CustomProperty value) { return(innerArray.IndexOf(value)); }
/// <summary> /// Determines whether a CustomProperty is in the CustomPropertyCollection. /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Contains(CustomProperty item) { return(innerArray.Contains(item)); }
/// <summary> /// Fill Write Service /// </summary> /// <param name="itemId"></param> /// <param name="hasWriteAccess"></param> /// <param name="itemValue"></param> private Helper.CustomProperties FillWriteService(string itemId, Type itemDataType, bool hasWriteAccess, ValueQT itemValues) { Helper.DataTypes dataTypeHelper = new DataTypes(); Helper.CustomProperties writeServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Item Id", "System.String", null, null, itemId); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; writeServiceColl.Properties.Add(customProperty); //create the DaItem value if (!itemValues.Data.GetType().IsArray) { //the DaItem VALUE is not an array customProperty = new DemoClient.Helper.CustomProperty("Value", "System.String", null, null, ValueConverter.ArrayToString(itemValues)); if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); dataTypeHelper.Type = itemDataType; customProperty = new DemoClient.Helper.CustomProperty("Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), null, null, dataTypeHelper.NativeDataType, typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Start Index", "System.String", null, null, ""); if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); } else { //DaItem VALUE is an Array customProperty = new DemoClient.Helper.CustomProperty("Value", "System.String", null, null, ValueConverter.DataToString(itemValues)); if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); Array dataArray = itemValues.Data as Array; if (dataArray.GetLowerBound(0) == 0) { dataTypeHelper.Type = itemDataType; customProperty = new DemoClient.Helper.CustomProperty("Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), null, null, dataTypeHelper.NativeDataType, typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); } else { string dataType = dataArray.GetType().ToString(); dataType = dataType.Remove(dataType.IndexOf('*')); dataTypeHelper.Type = System.Type.GetType(dataType); customProperty = new DemoClient.Helper.CustomProperty("Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), null, null, dataTypeHelper.NativeDataType, typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); } if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Start Index", "System.Int32", null, null, dataArray.GetLowerBound(0)); if (!hasWriteAccess) { customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } writeServiceColl.Properties.Add(customProperty); } return(writeServiceColl); }
/// <summary> /// DaSubscription Properties /// </summary> /// <param name="subscription"></param> internal bool DaSubscription(DaSubscription subscription) { panelBottom.Visible = true; this.daItem = null; daSubscription = subscription; daSession = null; aeSubscription = null; aeSession = null; Helper.DataTypes dataTypeHelper = new DataTypes(); this.panelBottom.Visible = true; //DaSubscription Name Helper.CustomProperties propServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Name", "System.String", "General", null, daSubscription.Name); propServiceColl.Properties.Add(customProperty); //DaSubscription Update Rate customProperty = new DemoClient.Helper.CustomProperty("Update Rate(ms)", "System.String", "General", null, daSubscription.RequestedUpdateRate); propServiceColl.Properties.Add(customProperty); //DaSubscription Revised Update Rate customProperty = new DemoClient.Helper.CustomProperty("Revised Update Rate(ms)", "System.String", "General", null, daSubscription.RevisedUpdateRate); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //DaSubscription Deadband customProperty = new DemoClient.Helper.CustomProperty("Deadband", "System.String", "General", null, daSubscription.Deadband.ToString()); propServiceColl.Properties.Add(customProperty); //DaSubscription Time Bias customProperty = new DemoClient.Helper.CustomProperty("Time Bias(min)", "System.String", "General", null, daSubscription.TimeBias); propServiceColl.Properties.Add(customProperty); //DaSubscription Locale Id ServerStatus status; if (ResultCode.SUCCEEDED(daSubscription.DaSession.GetStatus(out status, null))) { LocaleId.SelectedItem = daSubscription.LocaleId; LocaleId.LocaleIdList = status.SupportedLcIds; customProperty = new DemoClient.Helper.CustomProperty("Locale Id", "System.String", "General", null, daSubscription.LocaleId, typeof(Helper.LCIDEditor), typeof(Helper.LCIDEditor)); } else { customProperty = new DemoClient.Helper.CustomProperty("Locale Id", "System.String", "General", null, daSubscription.LocaleId); } propServiceColl.Properties.Add(customProperty); //DaSubscription Revised Keep Alive Time customProperty = new DemoClient.Helper.CustomProperty("Keep Alive Time(ms)", "System.String", "General", null, daSubscription.RequestedKeepAliveTime); propServiceColl.Properties.Add(customProperty); customProperty = new DemoClient.Helper.CustomProperty("Revised Keep Alive Time(ms)", "System.String", "General", null, daSubscription.RevisedKeepAliveTime); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); this.propertyGrid.PropertySort = PropertySort.Categorized; this.propertyGrid.SelectedObject = propServiceColl; return(true); }
/// <summary> /// AeSession Properties /// </summary> /// <param name="session"></param> internal bool AeSession(AeSession session) { panelBottom.Visible = true; this.daItem = null; daSubscription = null; daSession = null; aeSubscription = null; aeSession = session; Helper.DataTypes dataTypeHelper = new DataTypes(); this.panelBottom.Visible = true; //AeSession URL Helper.CustomProperties propServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("URL", "System.String", "General", null, aeSession.Url); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Locale Id ServerStatus status = null; if (ResultCode.SUCCEEDED(aeSession.GetStatus(out status, null))) { LocaleId.SelectedItem = aeSession.LocaleId; LocaleId.LocaleIdList = status.SupportedLcIds; customProperty = new DemoClient.Helper.CustomProperty("Locale Id", "System.String", "General", null, aeSession.LocaleId, typeof(Helper.LCIDEditor), typeof(Helper.LCIDEditor)); } else { customProperty = new DemoClient.Helper.CustomProperty("Locale Id", "System.String", "General", null, aeSession.LocaleId); } propServiceColl.Properties.Add(customProperty); //AeSession Client name customProperty = new DemoClient.Helper.CustomProperty("Client Name", "System.String", "General", null, aeSession.ClientName); propServiceColl.Properties.Add(customProperty); //AeSession Available filter criterias EnumFilterBy filters; if (ResultCode.SUCCEEDED(aeSession.QueryAvailableAeFilters(out filters, null))) { customProperty = new DemoClient.Helper.CustomProperty("Available Filter Criterias", "System.String", "General", null, GetFilter(filters)); } else { customProperty = new DemoClient.Helper.CustomProperty("Available Filter Criterias", "System.String", "General", null, ""); } customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Class Context EnumClassContext classContext = aeSession.ClassContext; customProperty = new DemoClient.Helper.CustomProperty("DCOM Class Context", typeof(EnumClassContext), "General", null, classContext); propServiceColl.Properties.Add(customProperty); if (status != null) { //AeSession Vendor info customProperty = new DemoClient.Helper.CustomProperty("Vendor Info", "System.String", "Status", null, status.VendorInfo); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Version customProperty = new DemoClient.Helper.CustomProperty("Version", "System.String", "Status", null, status.ProductVersion); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Start time customProperty = new DemoClient.Helper.CustomProperty("Start Time", "System.String", "Status", null, ValueConverter.DateTimeOptions(status.StartTime)); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Current time customProperty = new DemoClient.Helper.CustomProperty("Current Time", "System.String", "Status", null, ValueConverter.DateTimeOptions(status.CurrentTime)); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Last update time customProperty = new DemoClient.Helper.CustomProperty("Last Update Time", "System.String", "Status", null, ValueConverter.DateTimeOptions(status.LastUpdateTime)); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Status info customProperty = new DemoClient.Helper.CustomProperty("Status Info", "System.String", "Status", null, status.StatusInfo); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //AeSession Server state customProperty = new DemoClient.Helper.CustomProperty("Server State", "System.String", "Status", null, status.State); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); } this.propertyGrid.PropertySort = PropertySort.Categorized; this.propertyGrid.SelectedObject = propServiceColl; return(true); }
/// <summary> /// Show DaItem Properties /// </summary> /// <param name="daItem"></param> internal bool DaItem(DaItem item) { panelBottom.Visible = true; this.daItem = item; daSubscription = null; daSession = null; aeSubscription = null; aeSession = null; Helper.DataTypes dataTypeHelper = new DataTypes(); this.panelBottom.Visible = true; //Item Id Helper.CustomProperties propServiceColl = new DemoClient.Helper.CustomProperties(); Helper.CustomProperty customProperty = new DemoClient.Helper.CustomProperty("Item Id", "System.String", "General", null, daItem.Id); propServiceColl.Properties.Add(customProperty); //Item Path customProperty = new DemoClient.Helper.CustomProperty("Item Path", "System.String", "General", null, daItem.Path); propServiceColl.Properties.Add(customProperty); //Requested Data Type string dataType = daItem.NativeDatatype.FullName; if (dataType.Contains("*")) { dataType = dataType.Remove(dataType.IndexOf('*')); } dataTypeHelper.Type = System.Type.GetType(dataType); customProperty = new DemoClient.Helper.CustomProperty("Requested Data Type", dataTypeHelper.RequiredDataTypes.Values.GetType().ToString(), "General", null, dataTypeHelper.NativeDataType, typeof(Helper.DataTypeEditor), typeof(Helper.DataTypeEditor)); propServiceColl.Properties.Add(customProperty); //Deadband customProperty = new DemoClient.Helper.CustomProperty("Deadband", "System.String", "General", null, daItem.Deadband.ToString()); propServiceColl.Properties.Add(customProperty); //Native Data Type customProperty = new DemoClient.Helper.CustomProperty("Native Data Type", "System.String", "General", null, dataTypeHelper.NativeDataType); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //Access Rights string strAccesRights = ""; switch (daItem.AccessRights) { case EnumAccessRights.READABLE: strAccesRights = "read"; break; case EnumAccessRights.READWRITEABLE: strAccesRights = "read and write"; break; case EnumAccessRights.WRITEABLE: strAccesRights = "write"; break; } customProperty = new DemoClient.Helper.CustomProperty("Acces Rights", "System.String", "General", null, strAccesRights); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //Engineering Units Type string strEUType = ""; switch (daItem.EUType) { case EnumEUType.ANALOG: strEUType = "analog"; break; case EnumEUType.ENUMERATED: strEUType = "enumerated"; break; case EnumEUType.NOENUM: strEUType = "no"; break; } customProperty = new DemoClient.Helper.CustomProperty("EU Type", "System.String", "General", null, strEUType); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); //Engeneering Units Info string euInfo = ""; if (daItem.EUInfo != null) { euInfo = daItem.EUInfo.ToString(); } customProperty = new DemoClient.Helper.CustomProperty("EU Info", "System.String", "General", null, euInfo); customProperty.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; propServiceColl.Properties.Add(customProperty); this.propertyGrid.SelectedObject = propServiceColl; return(true); }