public ModelElement DoVerify(ModelElement element, AceModelRestricted model) { // For interface that are not PnP and can come and go, verify that they are still present. // (e.g. RemoteGPIB, etc.) // In most cases, nothing will need to be done to verify an interface. // Return a copy of the input element. // The following values need to be set in the returned element: // Verified = true means it has been through this method // Failed = true / false if (element == null) { return(null); } var elementCopy = element.MakeCopy(); IConfigDll hwconfig = _container.Resolve <IConfigDll>(AgentName); hwconfig.VerifyElement(elementCopy); var parent = model.FindEquivalentElement(elementCopy.Parent); if (parent != null) { elementCopy.Parent = parent; elementCopy.ParentId = parent.PersistentId; } return(elementCopy); }
public ArgMap GetEditableParameters(string deviceName, AceModelRestricted model) { var element = GetEditintElement(deviceName, model); var argmap = GetElementRepresentation(element); return(argmap); }
public SampleDiscoveryWatcher(IUnityContainer container, AceModelRestricted model, IRequestService rqstSvr) { _container = container; _model = model; _requestSvr = rqstSvr; RequestDiscoveryAction = RequestDiscovery; WaitingInterval = DEFAULT_INTERVAL; }
public List <string> GetManuallyAddableDevices(AceModelRestricted model) { var availableList = new List <string>(); availableList.Add(Consts.SAMPLE_INSTRUMENT); availableList.Add(Consts.SAMPLE_INTERFACE); return(availableList); }
private ModelInterface[] GetUnconfigedInterfaces(AceModelRestricted model) { IConfigDll hwconfig = _container.Resolve <IConfigDll>(AgentName); if ((hwconfig == null) || (model == null)) { return(Enumerable.Empty <ModelInterface>().ToArray()); } return(model.GetUnconfigedSampleInterfaces(hwconfig).ToArray()); }
public List <string> GetManuallyEditableDevices(AceModelRestricted model) { List <string> editableList = new List <string>(); var manualDevs = (from e in model.GetDevices() where (e is ModelDeviceSample) && (e.StaticallyDefined == true) select string.Format(Consts.EDITABLE_FORMATE, Consts.SAMPLE_INSTRUMENT, e.VisaName)).ToList <string>(); var manualIntfcs = (from e in model.GetInterfaces() where (e is ModelInterfaceSample) select string.Format(Consts.EDITABLE_FORMATE, Consts.SAMPLE_INTERFACE, e.VisaName)).ToList <string>(); editableList.AddRange(manualDevs); editableList.AddRange(manualIntfcs); return(editableList); }
private ModelElement GetAddingElement(string deviceName, AceModelRestricted model) { ModelElement element = null; if (deviceName.StartsWith(Consts.SAMPLE_INSTRUMENT, StringComparison.InvariantCultureIgnoreCase)) { element = GenerateAddingDevice(model); } else if (deviceName.StartsWith(Consts.SAMPLE_INTERFACE, StringComparison.InvariantCultureIgnoreCase)) { element = GenerateAddingInterface(model); } return(element); }
private ModelElement GetEditintElement(string deviceName, AceModelRestricted model) { string visa = string.Empty; if (deviceName.StartsWith(Consts.SAMPLE_INSTRUMENT, StringComparison.InvariantCultureIgnoreCase)) { visa = GetEditingDeviceVisaName(deviceName); } else if (deviceName.StartsWith(Consts.SAMPLE_INTERFACE, StringComparison.InvariantCultureIgnoreCase)) { visa = GetEditingInterfaceVisaName(deviceName); } var element = model.FindElementByVisaName(visa); return(element); }
private ModelElement GenerateAddingDevice(AceModelRestricted model) { var intfc = model.FindElementByVisaName(Consts.DEFAULT_INTFC_VISANAME) as ModelInterfaceSample; if (intfc == null) { intfc = new ModelInterfaceSample(); intfc.VisaInterfaceId = Consts.DEFAULT_INTFC_VISANAME; } var device = new ModelDeviceSample(); device.Parent = intfc; device.ParentId = intfc.PersistentId; device.StaticallyDefined = true; return(device); }
private ModelElement GenerateAddingInterface(AceModelRestricted model) { var intfc = new ModelInterfaceSample(); var activeInterfaces = model.GetInterfaces().Where(i => i.AgentName == AgentId).Select(e => e as ModelInterfaceSample) .OrderBy(i => i.VisaInterfaceId.ToUpper(), new SampleIOAgentComparer(Consts.VISA_PRIFIX)); var latestVisaInterface = activeInterfaces.LastOrDefault(); var visaIndex = latestVisaInterface.VisaInterfaceId.ToUpper().GetIndex(Consts.VISA_PRIFIX); var siclInterfaces = activeInterfaces.OrderBy(i => i.SiclInterfaceId, new SampleIOAgentComparer(Consts.SICL_PRIFIX)); var latestSiclInterface = siclInterfaces.LastOrDefault(); var siclIndex = (latestSiclInterface != null) ? latestVisaInterface.SiclInterfaceId.ToLower().GetIndex(Consts.SICL_PRIFIX) : -1; visaIndex++; siclIndex = siclIndex >= 0 ? ++siclIndex : 1; var visaIntfID = Consts.VISA_PRIFIX.GenerateNewPrifix(visaIndex); var siclIntfID = Consts.SICL_PRIFIX.GenerateNewPrifix(siclIndex); var luInterfaces = activeInterfaces.OrderBy(i => i.LogicalUnit, new LUComparer()); var latestLUIntf = luInterfaces.LastOrDefault(); var lu = Consts.DEFAULT_LU; if (latestLUIntf != null) { int luValue; if (int.TryParse(latestLUIntf.LogicalUnit, out luValue)) { luValue++; lu = luValue.ToString(); } else { lu = Consts.DEFAULT_LU; } } else { lu = Consts.DEFAULT_LU; } intfc.VisaInterfaceId = visaIntfID; intfc.SiclInterfaceId = siclIntfID; intfc.LogicalUnit = lu; intfc.StaticallyDefined = true; return(intfc); }
public List <ModelElement> DoDiscovery(ModelElement discoveryRoot, AceModelRestricted model) { // Discover devices on interfaces // If discoveryRoot is null or empty discovery devices on all interfaces associated with this agent. // If discoveryRoot is specified, verify the presence of the interface and discover all devices on it. // - The model paramenter contains elements that are currently known - treat it as read-only // - Add only newly discovered or deleted elements to the output list. // - Notes: // - Only devices are discovered here. Interfaces are discovered and added to the model in AutoConfig(). // - Elements in the output list will later be verified using DoVerify(). // - If we are not confident that a discovered device is the same as one already in the model, // then we should copy it to the output List so it will later be verified. //string doDiscoveryTitle = string.Format("DoDiscovery of {0}", (discoveryRoot != null) ? discoveryRoot.ToString() : "<null>"); //LogUtils.LogElements(_log, this, doDiscoveryTitle, model.GetInterfaces()); // Verbose if (_log != null && discoveryRoot != null) { var id = discoveryRoot.PersistentId; string msg = string.Format("Begin discovery of '{0}'", id); _log.Message(msg, LogUtils.MethodName(this)); } var list = new List <ModelElement>(); var intfc = discoveryRoot as ModelInterfaceSample; if (intfc != null) { IConfigDll hwconfig = _container.Resolve <IConfigDll>(AgentName); hwconfig.InitializeDll(); var intfcCopy = intfc.MakeCopy() as ModelInterfaceSample; var availableIntfcs = hwconfig.GetAvailableInterfaces() .Where(i => i is ModelInterfaceSample) .Select(i => i as ModelInterfaceSample); if (intfcCopy.IsInterfacePresent(availableIntfcs) || intfc.StaticallyDefined) { list.Add(intfcCopy); FindAndUpdateDevices(hwconfig, list, intfc, model); } hwconfig.UninitializeDll(); } return(list); }
public ModelElement ConstructElement(string name, ArgMap parameters, AceModelRestricted model) { ModelElement element = null; Dictionary <string, string> rawProperties = ApiDataRepresentation.ArgMapToPropertyDictionary(parameters); string id = rawProperties[Ace2ApiConstants.PersistentId_Parameter]; if (name.StartsWith(Consts.SAMPLE_INSTRUMENT) || name.Contains("::")) { element = ConstructDevice(id, rawProperties); } else { element = ConstructInterface(id, rawProperties); } if (element != null && element.Parent == null && element.ParentId.Length > 0) { element.Parent = model.FindElementById(element.ParentId); } return(element); }
public List<ModelElement> DoDiscovery(ModelElement discoveryRoot, AceModelRestricted model) { // Discover devices on interfaces // If discoveryRoot is null or empty discovery devices on all interfaces associated with this agent. // If discoveryRoot is specified, verify the presence of the interface and discover all devices on it. // - The model paramenter contains elements that are currently known - treat it as read-only // - Add only newly discovered or deleted elements to the output list. // - Notes: // - Only devices are discovered here. Interfaces are discovered and added to the model in AutoConfig(). // - Elements in the output list will later be verified using DoVerify(). // - If we are not confident that a discovered device is the same as one already in the model, // then we should copy it to the output List so it will later be verified. //string doDiscoveryTitle = string.Format("DoDiscovery of {0}", (discoveryRoot != null) ? discoveryRoot.ToString() : "<null>"); //LogUtils.LogElements(_log, this, doDiscoveryTitle, model.GetInterfaces()); // Verbose if (_log != null && discoveryRoot != null) { var id = discoveryRoot.PersistentId; string msg = string.Format("Begin discovery of '{0}'", id); _log.Message(msg, LogUtils.MethodName(this)); } var list = new List<ModelElement>(); var intfc = discoveryRoot as ModelInterfaceSample; if (intfc != null) { IConfigDll hwconfig = _container.Resolve<IConfigDll>(AgentName); hwconfig.InitializeDll(); var intfcCopy = intfc.MakeCopy() as ModelInterfaceSample; var availableIntfcs = hwconfig.GetAvailableInterfaces() .Where(i => i is ModelInterfaceSample) .Select(i => i as ModelInterfaceSample); if (intfcCopy.IsInterfacePresent(availableIntfcs) || intfc.StaticallyDefined) { list.Add(intfcCopy); FindAndUpdateDevices(hwconfig, list, intfc, model); } hwconfig.UninitializeDll(); } return list; }
public List<string> GetManuallyEditableDevices(AceModelRestricted model) { List<string> editableList = new List<string>(); var manualDevs = (from e in model.GetDevices() where (e is ModelDeviceSample) && (e.StaticallyDefined == true) select string.Format(Consts.EDITABLE_FORMATE, Consts.SAMPLE_INSTRUMENT, e.VisaName)).ToList<string>(); var manualIntfcs = (from e in model.GetInterfaces() where (e is ModelInterfaceSample) select string.Format(Consts.EDITABLE_FORMATE, Consts.SAMPLE_INTERFACE, e.VisaName)).ToList<string>(); editableList.AddRange(manualDevs); editableList.AddRange(manualIntfcs); return editableList; }
private void FindAndUpdateDevices(IConfigDll hwconfig, List<ModelElement> discoveredList, ModelInterfaceSample intfc, AceModelRestricted model) { var connectedDevices = hwconfig.GetAvailableDevices(intfc); discoveredList.AddRange(connectedDevices); }
public ModelInterface[] AutoConfig(AceModelRestricted model) { var interfacces = GetUnconfigedInterfaces(model); return(interfacces); }
public ModelElement DoVerify(ModelElement element, AceModelRestricted model) { // For interface that are not PnP and can come and go, verify that they are still present. // (e.g. RemoteGPIB, etc.) // In most cases, nothing will need to be done to verify an interface. // Return a copy of the input element. // The following values need to be set in the returned element: // Verified = true means it has been through this method // Failed = true / false if (element == null) return null; var elementCopy = element.MakeCopy(); IConfigDll hwconfig = _container.Resolve<IConfigDll>(AgentName); hwconfig.VerifyElement(elementCopy); var parent = model.FindEquivalentElement(elementCopy.Parent); if (parent != null) { elementCopy.Parent = parent; elementCopy.ParentId = parent.PersistentId; } return elementCopy; }
private ModelElement GenerateAddingInterface(AceModelRestricted model) { var intfc = new ModelInterfaceSample(); var activeInterfaces = model.GetInterfaces().Where(i => i.AgentName == AgentId).Select(e => e as ModelInterfaceSample) .OrderBy(i => i.VisaInterfaceId.ToUpper(), new SampleIOAgentComparer(Consts.VISA_PRIFIX)); var latestVisaInterface = activeInterfaces.LastOrDefault(); var visaIndex = latestVisaInterface.VisaInterfaceId.ToUpper().GetIndex(Consts.VISA_PRIFIX); var siclInterfaces = activeInterfaces.OrderBy(i => i.SiclInterfaceId, new SampleIOAgentComparer(Consts.SICL_PRIFIX)); var latestSiclInterface = siclInterfaces.LastOrDefault(); var siclIndex = (latestSiclInterface != null) ? latestVisaInterface.SiclInterfaceId.ToLower().GetIndex(Consts.SICL_PRIFIX) : -1; visaIndex++; siclIndex = siclIndex >= 0 ? ++siclIndex : 1; var visaIntfID = Consts.VISA_PRIFIX.GenerateNewPrifix(visaIndex); var siclIntfID = Consts.SICL_PRIFIX.GenerateNewPrifix(siclIndex); var luInterfaces = activeInterfaces.OrderBy(i => i.LogicalUnit, new LUComparer()); var latestLUIntf = luInterfaces.LastOrDefault(); var lu = Consts.DEFAULT_LU; if (latestLUIntf != null) { int luValue; if (int.TryParse(latestLUIntf.LogicalUnit, out luValue)) { luValue++; lu = luValue.ToString(); } else { lu = Consts.DEFAULT_LU; } } else { lu = Consts.DEFAULT_LU; } intfc.VisaInterfaceId = visaIntfID; intfc.SiclInterfaceId = siclIntfID; intfc.LogicalUnit = lu; intfc.StaticallyDefined = true; return intfc; }
public List<string> GetManuallyAddableDevices(AceModelRestricted model) { var availableList = new List<string>(); availableList.Add(Consts.SAMPLE_INSTRUMENT); availableList.Add(Consts.SAMPLE_INTERFACE); return availableList; }
public List<ModelElement> DeleteDevice(string name, AceModelRestricted model) { return DefaultDeleteAction.DefaultDeleteDevice(name, model); }
public static IEnumerable <ModelInterfaceSample> GetUnconfigedSampleInterfaces(this AceModelRestricted model, IConfigDll hwconfig) { var unconfigured = Enumerable.Empty <ModelInterfaceSample>(); if ((hwconfig != null) && (model != null)) { hwconfig.InitializeDll(); //ModelElement[] configuredInterfaceElements = model.GetInterfacesOfVisaType(this.VisaIntfTypeString); // EOS: unused, removed. var availableInterfaces = hwconfig.GetAvailableInterfaces().Where(i => i is ModelInterfaceSample).Select(i => i as ModelInterfaceSample); // TCPIP only configures 1 interface by default, but this pattern supports any number unconfigured = (from i in availableInterfaces where model.FindEquivalentElement(i) == null select i); hwconfig.UninitializeDll(); } return(unconfigured); }
public ModelInterface[] AutoConfig(AceModelRestricted model) { var interfacces = GetUnconfigedInterfaces(model); return interfacces; }
private ModelInterface[] GetUnconfigedInterfaces(AceModelRestricted model) { IConfigDll hwconfig = _container.Resolve<IConfigDll>(AgentName); if ((hwconfig == null) || (model == null)) return Enumerable.Empty<ModelInterface>().ToArray(); return model.GetUnconfigedSampleInterfaces(hwconfig).ToArray(); }
private ModelElement GetEditintElement(string deviceName, AceModelRestricted model) { string visa = string.Empty; if (deviceName.StartsWith(Consts.SAMPLE_INSTRUMENT, StringComparison.InvariantCultureIgnoreCase)) { visa = GetEditingDeviceVisaName(deviceName); } else if (deviceName.StartsWith(Consts.SAMPLE_INTERFACE, StringComparison.InvariantCultureIgnoreCase)) { visa = GetEditingInterfaceVisaName(deviceName); } var element = model.FindElementByVisaName(visa); return element; }
private ModelElement GetAddingElement(string deviceName, AceModelRestricted model) { ModelElement element = null; if (deviceName.StartsWith(Consts.SAMPLE_INSTRUMENT, StringComparison.InvariantCultureIgnoreCase)) { element = GenerateAddingDevice(model); } else if (deviceName.StartsWith(Consts.SAMPLE_INTERFACE, StringComparison.InvariantCultureIgnoreCase)) { element = GenerateAddingInterface(model); } return element; }
public List <ModelElement> DeleteDevice(string name, AceModelRestricted model) { return(DefaultDeleteAction.DefaultDeleteDevice(name, model)); }
public ArgMap GetManualAddParameters(string deviceName, AceModelRestricted model) { var element = GetAddingElement(deviceName, model); var argmap = GetElementRepresentation(element); return argmap; }
private void FindAndUpdateDevices(IConfigDll hwconfig, List <ModelElement> discoveredList, ModelInterfaceSample intfc, AceModelRestricted model) { var connectedDevices = hwconfig.GetAvailableDevices(intfc); discoveredList.AddRange(connectedDevices); }
private ModelElement GenerateAddingDevice(AceModelRestricted model) { var intfc = model.FindElementByVisaName(Consts.DEFAULT_INTFC_VISANAME) as ModelInterfaceSample; if (intfc == null) { intfc = new ModelInterfaceSample(); intfc.VisaInterfaceId = Consts.DEFAULT_INTFC_VISANAME; } var device = new ModelDeviceSample(); device.Parent = intfc; device.ParentId = intfc.PersistentId; device.StaticallyDefined = true; return device; }
public ModelElement ConstructElement(string name, ArgMap parameters, AceModelRestricted model) { ModelElement element = null; Dictionary<string, string> rawProperties = ApiDataRepresentation.ArgMapToPropertyDictionary(parameters); string id = rawProperties[Ace2ApiConstants.PersistentId_Parameter]; if (name.StartsWith(Consts.SAMPLE_INSTRUMENT) || name.Contains("::")) { element = ConstructDevice(id, rawProperties); } else { element = ConstructInterface(id, rawProperties); } if (element != null && element.Parent == null && element.ParentId.Length > 0) { element.Parent = model.FindElementById(element.ParentId); } return element; }
public ArgMap GetEditableParameters(string deviceName, AceModelRestricted model) { var element = GetEditintElement(deviceName, model); var argmap = GetElementRepresentation(element); return argmap; }