public static void SetAnalogEngineeringUnits(DemoDaAddressSpaceElement daElement, Double lowLimit, Double highLimit, EnumAccessRights accessRights) { ValueQT val = new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now); DaConstantProperty euType = new DaConstantProperty( 7, "EUType", "7", val); daElement.AddProperty(euType); DaProperty euHigh = new DaProperty(); euHigh.Id = 102; euHigh.Name = "High EU"; euHigh.Description = "High EU Description"; euHigh.ItemId = "102"; euHigh.Datatype = typeof(System.Double); euHigh.AccessRights = accessRights; daElement.AddProperty(euHigh); DaProperty euLow = new DaProperty(); euLow.Id = 103; euLow.Name = "Low EU"; euLow.Description = "Low EU Description"; euLow.ItemId = "103"; euLow.Datatype = typeof(System.Double); euLow.AccessRights = accessRights; daElement.AddProperty(euLow); }
/// <summary> /// QueryAddressSpaceElementProperties /// </summary> public override int QueryAddressSpaceElementProperties(string anElementID, out ArrayList aPopertyList) { aPopertyList = null; if (anElementID.StartsWith("stringBased")) { aPopertyList = new ArrayList(); DaProperty prop = new DaProperty(); prop.Id = 5555; prop.AccessRights = EnumAccessRights.READABLE; prop.Datatype = typeof(short); prop.Name = "type"; prop.ItemId = anElementID + Application.Instance.PropertyDelimiter + "objectType"; prop.Description = "Object Type"; DaProperty prop2 = new DaProperty(); prop2.Id = 5556; prop2.AccessRights = EnumAccessRights.READABLE; prop2.Datatype = typeof(short); prop2.Name = "type2"; prop2.ItemId = anElementID + Application.Instance.PropertyDelimiter + "objectType2"; prop2.Description = "Object Type2"; aPopertyList.Add(prop); aPopertyList.Add(prop2); } // end if return((int)EnumResultCode.S_OK); } // end QueryAddressSpaceElementProperties
/// <summary> /// Display DaProperty /// </summary> /// <param name="property"></param> public void DaProperty(DaProperty property) { //display the propertyes panelBottom.Visible = false; Helper.CustomProperties propertiesColl = new DemoClient.Helper.CustomProperties(); SetPropertyData(ref propertiesColl, property, property.Description); propertyGrid.SelectedObject = propertiesColl; }
} // end QueryProperties public int AddProperty(DaProperty aProperty) { if (aProperty != null) { m_properties.Add( aProperty.Id, aProperty); return((int)EnumResultCode.S_OK); } // end if else { return((int)EnumResultCode.S_FALSE); } // end if...else } // end AddProperty
public static void CreateAngle(DemoDaAddressSpaceElement daElement, String name, String description, String itemId, EnumAccessRights accessRights) { DaProperty angleProperty = new DaProperty(); angleProperty.Id = 6020; angleProperty.Name = name; angleProperty.Description = description; angleProperty.ItemId = itemId; angleProperty.Datatype = typeof(System.Int16); angleProperty.AccessRights = accessRights; daElement.AddProperty(angleProperty); }
/// <summary> /// Initializes a new instance of the <see cref="DaPropertyState"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="itemId">The item id.</param> /// <param name="property">The property.</param> /// <param name="namespaceIndex">Index of the namespace.</param> public DaPropertyState( ISystemContext context, string itemId, DaProperty property, ushort namespaceIndex) : base(null) { this.TypeDefinitionId = Opc.Ua.VariableTypeIds.DataItemType; this.Description = null; this.WriteMask = 0; this.UserWriteMask = 0; if (property != null) { Initialize(context, itemId, property, namespaceIndex); } }
/// <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); }
} // end HandleReadRequest /// <summary> /// Handles a write request /// </summary> public virtual void HandleWriteRequest(DaRequest aRequest) { if (aRequest.PropertyId != 0) { DaProperty daProperty = m_properties[aRequest.PropertyId] as DaProperty; if (daProperty != null) { daProperty.HandleWriteRequest(aRequest); } else { aRequest.Result = EnumResultCode.E_FAIL; aRequest.Complete(); } // end if ... else } else { HandleItemWriteRequest(aRequest); } // end if ... else } // end HandleWriteRequest
} // end ctr public override int QueryProperties(out ArrayList aPropertyList) { aPropertyList = new ArrayList(); DaProperty prop = new DaProperty(); prop.Id = 5555; prop.AccessRights = EnumAccessRights.READABLE; prop.Datatype = typeof(UInt16); prop.Name = "type"; prop.Description = "Object Type"; if (ItemId == null) { prop.ItemId = "objectType"; } else { prop.ItemId = ItemId + Application.Instance.PropertyDelimiter + "objectType"; } // end if ... else DaProperty prop2 = new DaProperty(); prop2.Id = 5556; prop2.AccessRights = EnumAccessRights.READABLE; prop2.Datatype = typeof(UInt16); prop2.Name = "type2"; prop2.Description = "Object Type2"; if (ItemId == null) { prop2.ItemId = "objectType2"; } else { prop2.ItemId = ItemId + Application.Instance.PropertyDelimiter + "objectType2"; } // end if ... else aPropertyList.Add(prop); aPropertyList.Add(prop2); return((int)EnumResultCode.S_OK); } // end QueryProperties
} // end ctr public override int QueryProperties(out ArrayList aPropertyList) { try { DaProperty property = new DaProperty(); property.Id = 101; property.AccessRights = EnumAccessRights.READABLE; property.Datatype = typeof(string); property.Name = "Descripiton"; property.ItemId = "Descripiton"; property.Description = "Item Descripiton"; aPropertyList = new ArrayList(); ((ArrayList)aPropertyList).Add(property); return((int)(EnumResultCode.S_OK)); } catch { aPropertyList = null; return((int)(EnumResultCode.E_FAIL)); } // end catch } // end QueryProperties
/// <summary> /// Initializes the node from the element. /// </summary> /// <param name="context">The context.</param> /// <param name="itemId">The item id.</param> /// <param name="property">The property.</param> /// <param name="namespaceIndex">Index of the namespace.</param> public void Initialize(ISystemContext context, string itemId, DaProperty property, ushort namespaceIndex) { m_itemId = itemId; m_property = property; if (property == null) { return; } this.NodeId = DaModelUtils.ConstructIdForDaElement(m_itemId, property.PropertyId, namespaceIndex); this.BrowseName = new QualifiedName(property.Name, namespaceIndex); this.DisplayName = new LocalizedText(property.Name); this.TypeDefinitionId = Opc.Ua.VariableTypeIds.PropertyType; this.Value = null; this.StatusCode = StatusCodes.BadWaitingForInitialData; this.Timestamp = DateTime.UtcNow; bool isArray = false; this.DataType = ComUtils.GetDataTypeId(property.DataType, out isArray); this.ValueRank = (isArray)?ValueRanks.OneOrMoreDimensions:ValueRanks.Scalar; this.ArrayDimensions = null; // assume that properties with item ids are writeable. the server may still reject the write. if (String.IsNullOrEmpty(property.ItemId)) { this.AccessLevel = AccessLevels.CurrentRead; } else { this.AccessLevel = AccessLevels.CurrentReadOrWrite; } this.UserAccessLevel = this.AccessLevel; this.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; this.Historizing = false; // add a reference to the parent node. NodeId parentNodeId = DaModelUtils.ConstructIdForDaElement(itemId, -1, namespaceIndex); this.AddReference(ReferenceTypeIds.HasProperty, true, parentNodeId); }
/// <summary> /// Gets the property item ids. /// </summary> /// <param name="itemId">The item id.</param> /// <param name="properties">The properties to update.</param> private void GetPropertyItemIds(string itemId, DaProperty[] properties) { string methodName = "IOPCItemProperties.LookupItemIDs"; int count = properties.Length; // get list of ids to request. int[] propertyIds = new int[count]; for (int ii = 0; ii < propertyIds.Length; ii++) { propertyIds[ii] = properties[ii].PropertyId; } // request the item ids. IntPtr pItemIds = IntPtr.Zero; IntPtr pErrors = IntPtr.Zero; try { IOPCItemProperties server = BeginComCall<IOPCItemProperties>(methodName, true); server.LookupItemIDs( itemId, count, propertyIds, out pItemIds, out pErrors); } catch (Exception e) { if (ComUtils.IsUnknownError(e, ResultIds.E_FAIL, ResultIds.E_UNKNOWNITEMID, ResultIds.E_INVALIDITEMID)) { ComUtils.TraceComError(e, methodName); } return; } finally { EndComCall(methodName); } // unmarshal results. string[] itemIds = ComUtils.GetUnicodeStrings(ref pItemIds, count, true); int[] errors = ComUtils.GetInt32s(ref pErrors, count, true); // update the objects. for (int ii = 0; ii < count; ii++) { if (errors[ii] >= 0) { properties[ii].ItemId = itemIds[ii]; } else { properties[ii].ItemId = null; } } }
/// <summary> /// Read the available non-built in properties from the server. /// </summary> /// <param name="itemId">The item id.</param> /// <param name="updateCache">if set to <c>true</c> the cache is updated.</param> /// <returns>The array of properties.</returns> public DaProperty[] ReadAvailableProperties(string itemId, bool updateCache) { string methodName = "IOPCItemProperties.QueryAvailableProperties"; // query for available properties. int count = 0; IntPtr pPropertyIds = IntPtr.Zero; IntPtr pDescriptions = IntPtr.Zero; IntPtr pDataTypes = IntPtr.Zero; try { IOPCItemProperties server = BeginComCall<IOPCItemProperties>(methodName, true); server.QueryAvailableProperties( itemId, out count, out pPropertyIds, out pDescriptions, out pDataTypes); } catch (Exception e) { if (ComUtils.IsUnknownError(e, ResultIds.E_FAIL, ResultIds.E_UNKNOWNITEMID, ResultIds.E_INVALIDITEMID)) { ComUtils.TraceComError(e, methodName); } return null; } finally { EndComCall(methodName); } // unmarshal results. int[] propertyIds = ComUtils.GetInt32s(ref pPropertyIds, count, true); string[] descriptions = ComUtils.GetUnicodeStrings(ref pDescriptions, count, true); short[] datatype = ComUtils.GetInt16s(ref pDataTypes, count, true); List<DaProperty> properties = new List<DaProperty>(); for (int ii = 0; ii < count; ii++) { // do not return any of the built in properties. if (propertyIds[ii] <= PropertyIds.TimeZone) { continue; } DaProperty property = new DaProperty(); property.PropertyId = propertyIds[ii]; property.Name = descriptions[ii]; property.DataType = datatype[ii]; properties.Add(property); } // fetch the item ids. if (properties.Count > 0) { DaProperty[] array = properties.ToArray(); GetPropertyItemIds(itemId, array); // update the cache. if (updateCache) { lock (m_cache) { DaElement element = null; if (m_cache.TryGetValue(itemId, out element)) { element.Properties = array; } } } return array; } return null; }
/// <summary> /// Create a list o items in the AddressSpace /// </summary> /// <param name="parentFolder"></param> /// <param name="itemCount"></param> /// <param name="itemType"></param> /// <param name="itemSetName"></param> private EnumResultCode CreateItems( AddressSpaceElement parentFolder, DaAddressSpaceElement resultItem, uint itemCount, Type itemType, bool generateRandomValues, string guid, bool isAnalogItem) { // Create item folder MyDaAddressSpaceElement itemFolder = new MyDaAddressSpaceElement(); itemFolder.Name = String.Format("TestItems_{0}", m_createdFolders); itemFolder.HasChildren = true; itemFolder.AccessRights = EnumAccessRights.READABLE; if (!parentFolder.AddChild(itemFolder)) { return(EnumResultCode.E_FAIL); } m_createdFolders++; //add guid to ItemSetId node ValueQT cacheValue = null; resultItem.GetCacheValue(ref cacheValue); string[] currentValue = cacheValue.Data as string[]; string[] newValue = new string[currentValue.Length + 1]; currentValue.CopyTo(newValue, 0); newValue[currentValue.Length] = itemFolder.ItemId + "#" + guid; resultItem.ValueChanged(new ValueQT(newValue, EnumQuality.GOOD, DateTime.Now)); // Add Start/Stop simulation command DaStartStopSimulationCommand simulationCmd = new DaStartStopSimulationCommand(); simulationCmd.Name = "StartStopSimulationCommand"; simulationCmd.HasChildren = true; if (!itemFolder.AddChild(simulationCmd)) { return(EnumResultCode.E_FAIL); } simulationCmd.ValueChanged(new ValueQT(false, EnumQuality.GOOD, DateTime.Now)); MyDaAddressSpaceElement param; // Add command parameters // item count parameter param = new MyDaAddressSpaceElement(DaStartStopSimulationCommand.ChangeIntervalParam, DaStartStopSimulationCommand.ChangeIntervalParamType); if (!simulationCmd.AddChild(param)) { return(EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT((uint)0, EnumQuality.GOOD, DateTime.Now)); // repeat count parameter param = new MyDaAddressSpaceElement(DaStartStopSimulationCommand.RepeatCountParam, DaStartStopSimulationCommand.RepeatCountParamType); if (!simulationCmd.AddChild(param)) { return(EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT((uint)0, EnumQuality.GOOD, DateTime.Now)); // incrementt parameter param = new MyDaAddressSpaceElement(DaStartStopSimulationCommand.IncrementParam, DaStartStopSimulationCommand.IncrementParamType); if (!simulationCmd.AddChild(param)) { return(EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT((uint)0, EnumQuality.GOOD, DateTime.Now)); // Add Delete Items command DaDeleteItemsCommand deleteItemsCmd = new DaDeleteItemsCommand(); deleteItemsCmd.Name = "DeleteItemsCommand"; deleteItemsCmd.HasChildren = true; if (!itemFolder.AddChild(deleteItemsCmd)) { return(EnumResultCode.E_FAIL); } deleteItemsCmd.ValueChanged(new ValueQT(false, EnumQuality.GOOD, DateTime.Now)); // Add items to list for (uint i = 0; i < itemCount; i++) { MyDaAddressSpaceElement item = new MyDaAddressSpaceElement(String.Format("TV_{0}", i), itemType); if (!itemFolder.AddChild(item)) { return(EnumResultCode.E_FAIL); } if (isAnalogItem) { DaConstantProperty euType = new DaConstantProperty( (int)EnumPropertyId.ITEM_EU_TYPE, "EUType", "7", new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now)); euType.AccessRights = EnumAccessRights.READABLE; item.AddProperty(euType); DaProperty euHigh = new DaProperty(); euHigh.Id = (int)EnumPropertyId.HIGH_EU; euHigh.Name = "High EU"; euHigh.Description = "High EU"; euHigh.ItemId = euHigh.Id.ToString(); euHigh.Datatype = typeof(System.Double); euHigh.AccessRights = EnumAccessRights.READABLE; item.AddProperty(euHigh); DaProperty euLow = new DaProperty(); euLow.Id = (int)EnumPropertyId.LOW_EU; euLow.Name = "Low EU"; euLow.Description = "Low EU"; euLow.ItemId = euLow.Id.ToString(); euLow.Datatype = typeof(System.Double); euLow.AccessRights = EnumAccessRights.READABLE; item.AddProperty(euLow); } if (generateRandomValues) { // item.ValueChanged(m_generator.GetRandomValueQT(item.Datatype)); } else { item.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); } } return(EnumResultCode.S_OK); }
} // end QueryProperties public virtual uint AddProperty(DaProperty aProperty) { m_properties.Add(aProperty.Id, aProperty); return((uint)EnumResultCode.S_OK); } // end AddProperty
/// <summary> /// ReadItemProperties /// </summary> private void ReadProperties() { TreeNode selectedNode = browseTreeView.SelectedNode; if (selectedNode == null) { return; } if (selectedNode.Tag == null) { return; } //get the session if (browseTreeView.Nodes.Count == 0) { return; } TreeNode rootNode = browseTreeView.Nodes[0]; if (rootNode == null) { return; } if (rootNode.Tag == null) { return; } if (Type.ReferenceEquals(rootNode.Tag.GetType(), typeof(DaSession))) { DaSession session = rootNode.Tag as DaSession; if (session == null) { return; } if (serviceWindow == null) { return; } if (Type.ReferenceEquals(selectedNode.Tag.GetType(), typeof(DaAddressSpaceElement))) { //get AddressSpaceElement Properties List DaAddressSpaceElement addressSpaceElem = selectedNode.Tag as DaAddressSpaceElement; if (addressSpaceElem == null) { return; } propertyWindow.ReadAddressSpaceElemProperties(session, addressSpaceElem.ItemId); propertyWindow.Show(dockPanel); } else if (Type.ReferenceEquals(selectedNode.Tag.GetType(), typeof(DaProperty))) { //get DaProperty Properties DaProperty property = selectedNode.Tag as DaProperty; if (property == null) { return; } propertyWindow.DaProperty(property); propertyWindow.Show(dockPanel); } } }
} // end ProcessCommandLine public int BuildAddressSpace() { try { MyCreator creator = (MyCreator)Application.Instance.Creator; // DA DaAddressSpaceRoot daRoot = Application.Instance.DaAddressSpaceRoot; #region CTT // Create the structure of nodes required for UA CTT Testing AddressSpaceElement cttFolder = creator.CreateMyDaAddressSpaceElement(); cttFolder.Name = "CTT"; cttFolder.HasChildren = true; if (!daRoot.AddChild(cttFolder)) { return((int)EnumResultCode.E_FAIL); } AddressSpaceElement staticFolder = creator.CreateMyDaAddressSpaceElement(); staticFolder.Name = "Static"; staticFolder.HasChildren = true; if (!cttFolder.AddChild(staticFolder)) { return((int)EnumResultCode.E_FAIL); } AddressSpaceElement allProfilesFolder = creator.CreateMyDaAddressSpaceElement(); allProfilesFolder.Name = "All Profiles"; allProfilesFolder.HasChildren = true; if (!staticFolder.AddChild(allProfilesFolder)) { return((int)EnumResultCode.E_FAIL); } MyDaAddressSpaceElement tag; #region Static Scalar elements for all data Types AddressSpaceElement scalarFolder = creator.CreateMyDaAddressSpaceElement(); scalarFolder.Name = "Scalar"; scalarFolder.HasChildren = true; if (!allProfilesFolder.AddChild(scalarFolder)) { return((int)EnumResultCode.E_FAIL); } tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Double", typeof(System.Double)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Boolean", typeof(System.Boolean)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Byte", typeof(System.Byte)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Date Time", typeof(System.DateTime)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Float", typeof(System.Single)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Guid", typeof(System.Guid)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int16", typeof(System.Int16)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int32", typeof(System.Int32)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int64", typeof(System.Int64)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("String", typeof(System.String)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Sbyte", typeof(System.SByte)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); // tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("ByteString", typeof(System.Byte[])); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("ByteString", typeof(System.Byte[][])); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } // tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Byte), 10, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt16", typeof(System.UInt16)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt32", typeof(System.UInt32)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt64", typeof(System.UInt64)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("XmlElement", typeof(System.Xml.XmlElement)); if (!scalarFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomValueQT(tag.Datatype)); #endregion #region Static Array elements for all data Types AddressSpaceElement arraysFolder = creator.CreateMyDaAddressSpaceElement(); arraysFolder.Name = "Arrays"; arraysFolder.HasChildren = true; if (!allProfilesFolder.AddChild(arraysFolder)) { return((int)EnumResultCode.E_FAIL); } int arrayLength = 10; tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Double", typeof(System.Double[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } // Set the first value of the array to a value smaller than 10e14 for CTT testing double[] doubleArrayVal = m_generator.GetRandomArray(typeof(System.Double), false, arrayLength, true) as double[]; doubleArrayVal[0] %= 10E+14; tag.ValueChanged(new ValueQT(doubleArrayVal, EnumQuality.GOOD, DateTime.Now)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Boolean", typeof(System.Boolean[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Boolean), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Byte", typeof(System.Byte[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Byte), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Date Time", typeof(System.DateTime[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.DateTime), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Float", typeof(System.Single[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } // Set the first value of the array to a value smaller than 10e5 for CTT testing float[] floatArrayVal = m_generator.GetRandomArray(typeof(System.Single), false, arrayLength, true) as float[]; floatArrayVal[0] %= 0xf10E + 5; tag.ValueChanged(new ValueQT(floatArrayVal, EnumQuality.GOOD, DateTime.Now)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Guid", typeof(System.Guid[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Guid), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int16", typeof(System.Int16[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Int16), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int32", typeof(System.Int32[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Int32), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int64", typeof(System.Int64[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Int64), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("String", typeof(System.String[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.String), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Sbyte", typeof(System.SByte[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.SByte), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("ByteString", typeof(System.Byte[][])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Byte), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt16", typeof(System.UInt16[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.UInt16), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt32", typeof(System.UInt32[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.UInt32), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt64", typeof(System.UInt64[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.UInt64), arrayLength, true)); tag = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("XmlElement", typeof(System.Xml.XmlElement[])); if (!arraysFolder.AddChild(tag)) { return((int)EnumResultCode.E_FAIL); } tag.ValueChanged(m_generator.GetRandomArrayValueQT(typeof(System.Xml.XmlElement), arrayLength, true)); #endregion AddressSpaceElement daFolder = creator.CreateMyDaAddressSpaceElement(); daFolder.Name = "DA Profile"; daFolder.HasChildren = true; if (!staticFolder.AddChild(daFolder)) { return((int)EnumResultCode.E_FAIL); } #region DataItem elements for AllProfiles folder AddressSpaceElement dataItemFolder = creator.CreateMyDaAddressSpaceElement(); dataItemFolder.Name = "DataItem"; dataItemFolder.HasChildren = true; if (!daFolder.AddChild(dataItemFolder)) { return((int)EnumResultCode.E_FAIL); } MyDaAddressSpaceElement dataItem; // Sbyte dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("SByte", typeof(System.SByte)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } DaProperty valuePrecision = new DaProperty(); valuePrecision.Id = 111; valuePrecision.Name = "ValuePrecision"; valuePrecision.Description = "ValuePrecision"; valuePrecision.ItemId = valuePrecision.Id.ToString(); valuePrecision.Datatype = typeof(System.Double); valuePrecision.AccessRights = EnumAccessRights.READABLE; dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Byte dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Byte", typeof(System.Byte)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Int16 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int16", typeof(System.Int16)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // UInt16 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt16", typeof(System.UInt16)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Int32 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int32", typeof(System.Int32)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // UInt32 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt32", typeof(System.UInt32)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Int64 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int64", typeof(System.Int64)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // UInt64 dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt64", typeof(System.UInt64)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Double dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Double", typeof(System.Double)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // Float dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Float", typeof(System.Single)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // String dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("String", typeof(System.String)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); // DateTime dataItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("DateTime", typeof(System.DateTime)); if (!dataItemFolder.AddChild(dataItem)) { return((int)EnumResultCode.E_FAIL); } dataItem.AddProperty(valuePrecision); dataItem.ValueChanged(m_generator.GetRandomValueQT(dataItem.Datatype)); #endregion #region AnalogType elements for AllProfiles folder AddressSpaceElement analogTypeFolder = creator.CreateMyDaAddressSpaceElement(); analogTypeFolder.Name = "AnalogType"; analogTypeFolder.HasChildren = true; if (!daFolder.AddChild(analogTypeFolder)) { return((int)EnumResultCode.E_FAIL); } MyDaAddressSpaceElement analogTypeItem; // Sbyte analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("SByte", typeof(SByte)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } DaConstantProperty euTypeProperty = new DaConstantProperty( (int)EnumPropertyId.ITEM_EU_TYPE, "EUType", "7", new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now)); euTypeProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(euTypeProperty); DaProperty euHighProperty = new DaProperty(); euHighProperty.Id = (int)EnumPropertyId.HIGH_EU; euHighProperty.Name = "High EU"; euHighProperty.Description = "High EU"; euHighProperty.ItemId = euHighProperty.Id.ToString(); euHighProperty.Datatype = typeof(System.Double); euHighProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(euHighProperty); DaProperty euLowProperty = new DaProperty(); euLowProperty.Id = (int)EnumPropertyId.LOW_EU; euLowProperty.Name = "Low EU"; euLowProperty.Description = "Low EU"; euLowProperty.ItemId = euLowProperty.Id.ToString(); euLowProperty.Datatype = typeof(System.Double); euLowProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(euLowProperty); DaProperty irHighProperty = new DaProperty(); irHighProperty.Id = (int)EnumPropertyId.HIGH_INSTRUMENT_RANGE; irHighProperty.Name = "High InstrumentRange"; irHighProperty.Description = "High InstrumentRange"; irHighProperty.ItemId = irHighProperty.Id.ToString(); irHighProperty.Datatype = typeof(System.Double); irHighProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(irHighProperty); DaProperty irLowProperty = new DaProperty(); irLowProperty.Id = (int)EnumPropertyId.LOW_INSTRUMENT_RANGE; irLowProperty.Name = "Low InstrumentRange"; irLowProperty.Description = "Low InstrumentRange"; irLowProperty.ItemId = irLowProperty.Id.ToString(); irLowProperty.Datatype = typeof(System.Double); irLowProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(irLowProperty); DaProperty euUnitsProperty = new DaProperty(); euUnitsProperty.Id = (int)EnumPropertyId.EU_UNITS; euUnitsProperty.Name = "EU Units"; euUnitsProperty.Description = "EU Units"; euUnitsProperty.ItemId = euUnitsProperty.Id.ToString(); euUnitsProperty.Datatype = typeof(System.Double); euUnitsProperty.AccessRights = EnumAccessRights.READABLE; analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Byte analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Byte", typeof(Byte)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Int16 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int16", typeof(Int16)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // UInt16 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt16", typeof(UInt16)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Int32 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int32", typeof(Int32)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // UInt32 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt32", typeof(UInt32)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Int64 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int64", typeof(Int64)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // UInt64 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt64", typeof(UInt64)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Double analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Double", typeof(Double)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); // Float analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Float", typeof(float)); if (!analogTypeFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(0, EnumQuality.GOOD, DateTime.Now)); #endregion #region AnalogTypeArray elements for AllProfiles folder AddressSpaceElement analogTypeArraysFolder = creator.CreateMyDaAddressSpaceElement(); analogTypeArraysFolder.Name = "AnalogType Arrays"; analogTypeArraysFolder.HasChildren = true; if (!daFolder.AddChild(analogTypeArraysFolder)) { return((int)EnumResultCode.E_FAIL); } // Int16 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int16", typeof(Int16[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new Int16[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, EnumQuality.GOOD, DateTime.Now)); // Int32 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Int32", typeof(Int32[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new Int32[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }, EnumQuality.GOOD, DateTime.Now)); // UInt16 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt16", typeof(UInt16[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new UInt16[] { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }, EnumQuality.GOOD, DateTime.Now)); // UInt32 analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("UInt32", typeof(UInt32[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new UInt32[] { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, EnumQuality.GOOD, DateTime.Now)); // Float analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Float", typeof(float[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f }, EnumQuality.GOOD, DateTime.Now)); // Double analogTypeItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("Double", typeof(Double[])); if (!analogTypeArraysFolder.AddChild(analogTypeItem)) { return((int)EnumResultCode.E_FAIL); } analogTypeItem.AddProperty(euTypeProperty); analogTypeItem.AddProperty(euHighProperty); analogTypeItem.AddProperty(euLowProperty); analogTypeItem.AddProperty(irHighProperty); analogTypeItem.AddProperty(irLowProperty); analogTypeItem.AddProperty(euUnitsProperty); analogTypeItem.ValueChanged(new ValueQT(new Double[] { 9.00001, 9.0002, 9.003, 9.04, 9.5, 9.06, 9.007, 9.008, 9.0009 }, EnumQuality.GOOD, DateTime.Now)); #endregion #endregion #region Test Module AddressSpaceElement testFolder = creator.CreateMyDaAddressSpaceElement(); testFolder.Name = "Test Folder"; testFolder.HasChildren = true; if (!daRoot.AddChild(testFolder)) { return((int)EnumResultCode.E_FAIL); } #region CreateItems Command // Add Create Items command DaCreateItemsCommand createItemsCmd = (DaCreateItemsCommand)creator.CreateMyDaCreateItemsCommand(); createItemsCmd.Name = "CreateItemsCommand"; createItemsCmd.HasChildren = true; if (!testFolder.AddChild(createItemsCmd)) { return((int)EnumResultCode.E_FAIL); } createItemsCmd.ValueChanged(new ValueQT(false, EnumQuality.GOOD, DateTime.Now)); MyDaAddressSpaceElement param; // item count parameter param = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement(DaCreateItemsCommand.ItemCountParam, DaCreateItemsCommand.ItemCountParamType); if (!createItemsCmd.AddChild(param)) { return((int)EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT((uint)0, EnumQuality.GOOD, DateTime.Now)); // item type parameter param = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement(DaCreateItemsCommand.ItemTypeParam, DaCreateItemsCommand.ItemTypeParamType); if (!createItemsCmd.AddChild(param)) { return((int)EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT((uint)0, EnumQuality.GOOD, DateTime.Now)); // item is analog parameter param = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement(DaCreateItemsCommand.ItemIsAnalogParam, DaCreateItemsCommand.ItemIsAnalogParamType); param.AccessRights = EnumAccessRights.READWRITEABLE; if (!createItemsCmd.AddChild(param)) { return((int)EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT(false, EnumQuality.GOOD, DateTime.Now)); // item set result parameter param = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement(DaCreateItemsCommand.ItemSetIdParam, DaCreateItemsCommand.ItemSetIdParamType); param.AccessRights = EnumAccessRights.READABLE; if (!createItemsCmd.AddChild(param)) { return((int)EnumResultCode.E_FAIL); } param.ValueChanged(new ValueQT(new string[0], EnumQuality.GOOD, DateTime.Now)); #endregion #region Analog Items MyDaAddressSpaceElement analogItem; analogItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("AnalogItem_1", typeof(double)); if (!testFolder.AddChild(analogItem)) { return((int)EnumResultCode.E_FAIL); } DaConstantProperty euType = new DaConstantProperty( (int)EnumPropertyId.ITEM_EU_TYPE, "EUType", "7", new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now)); euType.AccessRights = EnumAccessRights.READABLE; analogItem.AddProperty(euType); DaProperty euHigh = new DaProperty(); euHigh.Id = (int)EnumPropertyId.HIGH_EU; euHigh.Name = "High EU"; euHigh.Description = "High EU"; euHigh.ItemId = euHigh.Id.ToString(); euHigh.Datatype = typeof(System.Double); euHigh.AccessRights = EnumAccessRights.READABLE; analogItem.AddProperty(euHigh); DaProperty euLow = new DaProperty(); euLow.Id = (int)EnumPropertyId.LOW_EU; euLow.Name = "Low EU"; euLow.Description = "Low EU"; euLow.ItemId = euLow.Id.ToString(); euLow.Datatype = typeof(System.Double); euLow.AccessRights = EnumAccessRights.READABLE; analogItem.AddProperty(euLow); analogItem.ValueChanged(new ValueQT(0.0, EnumQuality.GOOD, DateTime.Now)); analogItem = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement("AnalogItem_2", typeof(double)); if (!testFolder.AddChild(analogItem)) { return((int)EnumResultCode.E_FAIL); } analogItem.AddProperty(euType); analogItem.AddProperty(euHigh); analogItem.AddProperty(euLow); analogItem.ValueChanged(new ValueQT(1.0, EnumQuality.GOOD, DateTime.Now)); #endregion #endregion } catch (Exception exc) { Trace( EnumTraceLevel.ERR, EnumTraceGroup.USER1, "OpcServer:BuildAddressSpace", exc.ToString()); return((int)EnumResultCode.E_FAIL); } // end try...catch return((int)EnumResultCode.S_OK); } // end BuildAddressSpace
/// <summary> /// Constructs a property node for a DA property. /// </summary> /// <param name="context">The context.</param> /// <param name="parentId">The parent id.</param> /// <param name="property">The property.</param> /// <param name="namespaceIndex">Index of the namespace.</param> /// <returns>The property node.</returns> public static PropertyState ConstructProperty(ISystemContext context, string parentId, DaProperty property, ushort namespaceIndex) { return new DaPropertyState(context, parentId, property, namespaceIndex); }
} // end ProcessCommandLine public int BuildAddressSpace() { try { MyDaAddressSpaceElement tag, node; tag = new MyDaAddressSpaceElement(); tag.Name = "accept"; tag.Type = MyDaAddressSpaceElement.TYPE_ACCEPT; tag.AccessRights = EnumAccessRights.READWRITEABLE; tag.Datatype = typeof(Int32); tag.IoMode = EnumIoMode.POLL; Application.Instance.DaAddressSpaceRoot.AddChild(tag); node = new MyDaAddressSpaceElement(); node.Name = "maths"; node.Type = MyDaAddressSpaceElement.TYPE_NODEMATH; node.IoMode = EnumIoMode.NONE; node.HasChildren = true; Application.Instance.DaAddressSpaceRoot.AddChild(node); g_sin = new MyDaAddressSpaceElement(); g_sin.Name = "sin"; g_sin.Type = MyDaAddressSpaceElement.TYPE_SINE; g_sin.AccessRights = EnumAccessRights.READABLE; g_sin.Datatype = typeof(double); g_sin.IoMode = EnumIoMode.REPORT; node.AddChild(g_sin); g_sin.SetEUInfoAnalog(-1.0, 1.0); DaProperty property = new DaProperty(); property.Id = 6020; property.Name = "Angle"; property.Description = "Angle Description"; property.ItemId = property.Name; property.Datatype = typeof(short); property.AccessRights = EnumAccessRights.READWRITEABLE; g_sin.AddProperty(property); node = new MyDaAddressSpaceElement(); node.Name = "random"; node.Type = MyDaAddressSpaceElement.TYPE_NODERANDOM; node.IoMode = EnumIoMode.NONE; node.HasChildren = true; Application.Instance.DaAddressSpaceRoot.AddChild(node); g_rand100ms = new MyDaAddressSpaceElement(); g_rand100ms.Name = "100ms"; g_rand100ms.Type = MyDaAddressSpaceElement.TYPE_RANDOM_100MS; g_rand100ms.AccessRights = EnumAccessRights.READABLE; g_rand100ms.Datatype = typeof(Int32); g_rand100ms.IoMode = EnumIoMode.REPORT; node.AddChild(g_rand100ms); g_rand1s = new MyDaAddressSpaceElement(); g_rand1s.Name = "1s"; g_rand1s.Type = MyDaAddressSpaceElement.TYPE_RANDOM_1S; g_rand1s.AccessRights = EnumAccessRights.READABLE; g_rand1s.Datatype = typeof(Int32); g_rand1s.IoMode = EnumIoMode.REPORT; node.AddChild(g_rand1s); // AE MyAeAddressSpaceElement computer = new MyAeAddressSpaceElement(); computer.Name = "computer"; computer.HasChildren = true; Application.Instance.AeAddressSpaceRoot.AddChild(computer); MyAeAddressSpaceElement clock = new MyAeAddressSpaceElement(); clock.Name = "clock"; clock.HasChildren = true; computer.AddChild(clock); MyAeAddressSpaceElement timer = new MyAeAddressSpaceElement(); timer.Name = "timer"; timer.HasChildren = false; clock.AddChild(timer); timer = new MyAeAddressSpaceElement(); timer.Name = "time slot 1"; timer.HasChildren = false; clock.AddChild(timer); } catch (Exception exc) { Trace( EnumTraceLevel.ERR, EnumTraceGroup.USER1, "OpcServer:BuildAddressSpace", exc.ToString()); return((int)EnumResultCode.E_FAIL); } // end try...catch return((int)EnumResultCode.S_OK); } // end BuildAddressSpace