} // end constructor public override int HandleReadRequests() { int count = Requests.Count; for (int i = 0; i < count; i++) { DaRequest request = Requests[i] as DaRequest; if ((request != null) && (request.ProgressRequestState(EnumRequestState.CREATED, EnumRequestState.INPROGRESS) == true)) { if (request.PropertyId == 0) { // get address space element value // take the toolkit cache value ValueQT valueQT = null; request.AddressSpaceElement.GetCacheValue(ref valueQT); request.Value = valueQT; request.Result = EnumResultCode.S_OK; } else { // get property value // get the value from the address space element MyDaAddressSpaceElement element = request.AddressSpaceElement as MyDaAddressSpaceElement; request.Value = new ValueQT(element.ObjectType, EnumQuality.GOOD, DateTime.Now); request.Result = EnumResultCode.S_OK; } // end if ... else } // end if } // end for return(CompleteRequests()); } // end HandleReadRequests
public void RebuildRandomAddressSpace(AddressSpaceElement objBase) { if (objBase == null) { return; } if (!objBase.Name.Equals("ObjectBased")) { return; } Random rand = new Random(); ReconfigHandles[0] = new MyDaAddressSpaceElement(); ReconfigHandles[0].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[0].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[0].Datatype = typeof(Int32); ReconfigHandles[0].IoMode = EnumIoMode.REPORT; ReconfigHandles[0].HasChildren = true; ReconfigHandles[0].ObjectType = 3; objBase.AddChild(ReconfigHandles[0]); ReconfigHandles[1] = new MyDaAddressSpaceElement(); ReconfigHandles[1].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[1].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[1].Datatype = typeof(Int32); ReconfigHandles[1].IoMode = EnumIoMode.REPORT; ReconfigHandles[1].ObjectType = 4; objBase.AddChild(ReconfigHandles[1]); ReconfigHandles[2] = new MyDaAddressSpaceElement(); ReconfigHandles[2].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[2].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[2].Datatype = typeof(Int32); ReconfigHandles[2].IoMode = EnumIoMode.REPORT; ReconfigHandles[2].ObjectType = 5; ReconfigHandles[0].AddChild(ReconfigHandles[2]); }
} // end ProcessCommandLine public void BuildAddressSpace() { Random rand = new Random(); MyDaAddressSpaceElement tag; ObjectBased = new MyDaAddressSpaceElement(); ObjectBased.Name = "ObjectBased"; ObjectBased.IoMode = EnumIoMode.NONE; ObjectBased.HasChildren = true; ObjectBased.ObjectType = 1; Application.Instance.DaAddressSpaceRoot.AddChild(ObjectBased); tag = new MyDaAddressSpaceElement(); tag.Name = "T1"; tag.AccessRights = EnumAccessRights.READWRITEABLE; tag.Datatype = typeof(Byte); tag.IoMode = EnumIoMode.POLL; tag.ObjectType = 2; ObjectBased.AddChild(tag); tag = new MyDaAddressSpaceElement(); tag.Name = "T2"; tag.AccessRights = EnumAccessRights.READWRITEABLE; tag.Datatype = typeof(Byte); tag.IoMode = EnumIoMode.POLL; tag.ObjectType = 2; ObjectBased.AddChild(tag); tag = new MyDaAddressSpaceElement(); tag.Name = "T3"; tag.AccessRights = EnumAccessRights.READWRITEABLE; tag.Datatype = typeof(Byte); tag.IoMode = EnumIoMode.POLL; tag.ObjectType = 2; ObjectBased.AddChild(tag); ReconfigHandles[0] = new MyDaAddressSpaceElement(); ReconfigHandles[0].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[0].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[0].Datatype = typeof(Int32); ReconfigHandles[0].IoMode = EnumIoMode.REPORT; ReconfigHandles[0].HasChildren = true; ReconfigHandles[0].ObjectType = 3; ObjectBased.AddChild(ReconfigHandles[0]); ReconfigHandles[1] = new MyDaAddressSpaceElement(); ReconfigHandles[1].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[1].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[1].Datatype = typeof(Int32); ReconfigHandles[1].IoMode = EnumIoMode.REPORT; ReconfigHandles[1].ObjectType = 4; ObjectBased.AddChild(ReconfigHandles[1]); ReconfigHandles[2] = new MyDaAddressSpaceElement(); ReconfigHandles[2].Name = String.Format("R{0}", rand.Next()); ReconfigHandles[2].AccessRights = EnumAccessRights.READWRITEABLE; ReconfigHandles[2].Datatype = typeof(Int32); ReconfigHandles[2].IoMode = EnumIoMode.REPORT; ReconfigHandles[2].ObjectType = 5; ReconfigHandles[0].AddChild(ReconfigHandles[2]); }
} // end QueryAddressSpaceElementData public override int QueryAddressSpaceElementChildren(string anElementID, ArrayList aChildrenList) { MyDaAddressSpaceElement child = null; if (anElementID.Length == 0) { child = new MyDaAddressSpaceElement(); child.Name = "stringBased"; child.IoMode = EnumIoMode.NONE; child.ItemId = "stringBased"; child.HasChildren = true; aChildrenList.Add(child); } else if (anElementID == "stringBased") { child = new MyDaAddressSpaceElement(); child.Name = "N1"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte[]); child.IoMode = EnumIoMode.REPORT; child.HasChildren = true; aChildrenList.Add(child); child = new MyDaAddressSpaceElement(); child.Name = "N2"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte[]); child.IoMode = EnumIoMode.REPORT; child.HasChildren = true; aChildrenList.Add(child); child = new MyDaAddressSpaceElement(); child.Name = "T1"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte); child.IoMode = EnumIoMode.REPORT; child.HasChildren = false; aChildrenList.Add(child); } else if (anElementID == "stringBased.N1") { child = new MyDaAddressSpaceElement(); child.Name = "T1"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte); child.IoMode = EnumIoMode.REPORT; child.HasChildren = false; aChildrenList.Add(child); } else if (anElementID == "stringBased.N2") { child = new MyDaAddressSpaceElement(); child.Name = "T1"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte); child.IoMode = EnumIoMode.REPORT; child.HasChildren = false; aChildrenList.Add(child); child = new MyDaAddressSpaceElement(); child.Name = "T2"; child.ItemId = anElementID + Application.Instance.AddressSpaceDelimiter + child.Name; child.AccessRights = EnumAccessRights.READWRITEABLE; child.Datatype = typeof(byte); child.IoMode = EnumIoMode.REPORT; child.HasChildren = false; aChildrenList.Add(child); } // end if ... else return((int)EnumResultCode.S_OK); }