public override ModelElement MakeCopy() { var device = new ModelDeviceSample(); CopyDataTo(device); return(device); }
private void VerifyDevice(ModelDeviceSample device) { var parentElement = device.Parent; if (parentElement != null) { var parentInterface = parentElement as ModelInterfaceSample; if (parentInterface != null) { // Check if the device is still present if (IsDevicePresentProc(device, parentInterface)) { device.Verified = true; device.Failed = false; } else { device.FailedReason = AgentKeys.FailedReason_DeviceNotVerified; } } else { device.FailedReason = AgentKeys.FailedReason_NoVisaInterface; } } }
private ModelDeviceSample ConstructInstrument(XElement instrumentElement) { ModelDeviceSample device = null; var manufactureAttr = instrumentElement.Attribute(Consts.MANUFACTURE_ATTR); var modelAttr = instrumentElement.Attribute(Consts.MODEL_ATTR); var serialNumberAttr = instrumentElement.Attribute(Consts.SERIAL_NUMBER_ATTR); var firmwareVersionAttr = instrumentElement.Attribute(Consts.FIRMWARE_VERSION_ATTR); var ipAddressAttr = instrumentElement.Attribute(Consts.IPADDRESS_ATTR); var deviceNameAttr = instrumentElement.Attribute(Consts.DEVICE_NAME_ATTR); if (manufactureAttr != null && modelAttr != null && serialNumberAttr != null && firmwareVersionAttr != null && ipAddressAttr != null && deviceNameAttr != null) { device = new ModelDeviceSample(); device.Manufacturer = manufactureAttr.Value; device.ModelNumber = modelAttr.Value; device.SerialNumber = serialNumberAttr.Value; device.FirmwareRevision = firmwareVersionAttr.Value; device.IPAddress = ipAddressAttr.Value; device.DeviceName = deviceNameAttr.Value; } return device; }
private bool IsDevicePresentProc(ModelDeviceSample deviceToCheck, ModelInterfaceSample parentInterface) { bool isPresent = false; var hwDetector = GenerateHardwareDetector(); if (hwDetector != null) { var availableDevices = hwDetector.GetConnectedInstruments(parentInterface); isPresent = deviceToCheck.IsDevicePresent(availableDevices); } return(isPresent); }
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 ModelDevice ReconstituteDevice(DeviceDataRecord raw) { if (raw == null) { return(null); } if (!CanReconstituteThis(raw)) { return(null); } var device = new ModelDeviceSample(); ExtractCommonDevicePropertiesFromNVPairs(raw, device); device.IPAddress = raw.GetString(Consts.IPADDRESS_KEY); device.DeviceName = raw.GetString(Consts.DEVICENAME_KEY); device.Dirty = false; return(device); }
public static bool IsDevicePresent(this ModelDeviceSample deviceToCheck, IEnumerable <ModelDevice> availableDevices) { bool isPresent = false; // If we didn't get a ModelDeviceTcpip or it doesn't have a VisaName, it's not present if (deviceToCheck == null || string.IsNullOrWhiteSpace(deviceToCheck.VisaName)) { return(false); } foreach (var availableDevice in availableDevices) { if (availableDevice.IsEquivalent(deviceToCheck)) { isPresent = true; break; } } return(isPresent); }
private static void AddInfoToDevice(DeviceDataRecord raw, ModelDeviceSample specificDevice) { raw.AddProperty(Consts.IPADDRESS_KEY, specificDevice.IPAddress); raw.AddProperty(Consts.DEVICENAME_KEY, specificDevice.DeviceName); }
public void VerifyElementTestDevice() { var intfc1 = new ModelInterfaceSample { VisaInterfaceId = "SAMP0", SiclInterfaceId = "samp", LogicalUnit = "100" }; var instrument1 = new ModelDeviceSample { Manufacturer = "KT", ModelNumber = "DEV001", SerialNumber = "X01234", FirmwareRevision = "1.0.0.1", IPAddress = "192.168.56.128", DeviceName = "inst0" }; instrument1.Parent = intfc1; instrument1.ParentId = intfc1.PersistentId; var hwconfig1 = GenerateHwConfig(); hwconfig1.VerifyElement(instrument1); Assert.IsTrue(!instrument1.Failed); Assert.IsTrue(instrument1.Verified); var intfc2 = new ModelInterfaceSample { VisaInterfaceId = "SAMP1", SiclInterfaceId = "samp1", LogicalUnit = "101" }; var instrument2 = new ModelDeviceSample { Manufacturer = "KT", ModelNumber = "DEV001", SerialNumber = "X01234", FirmwareRevision = "1.0.0.1", IPAddress = "192.168.56.130", DeviceName = "inst0" }; instrument2.Parent = intfc2; instrument2.ParentId = intfc2.PersistentId; var hwconfig2 = GenerateHwConfig(); hwconfig2.VerifyElement(instrument2); Assert.IsTrue(instrument2.Failed); Assert.IsTrue(!instrument2.Verified); }
private static ModelDeviceSample GenerateSampleDeice(string manufacture, string model, string serialNumber, string firmwareVersion, string ipAddress, string deviceName) { var sampleDevice = new ModelDeviceSample(); sampleDevice.Manufacturer = manufacture; sampleDevice.ModelNumber = model; sampleDevice.SerialNumber = serialNumber; sampleDevice.FirmwareRevision = firmwareVersion; sampleDevice.IPAddress = ipAddress; sampleDevice.DeviceName = deviceName; return sampleDevice; }
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 ModelDevice ReconstituteDevice(DeviceDataRecord raw) { if (raw == null) return null; if (!CanReconstituteThis(raw)) return null; var device = new ModelDeviceSample(); ExtractCommonDevicePropertiesFromNVPairs(raw, device); device.IPAddress = raw.GetString(Consts.IPADDRESS_KEY); device.DeviceName = raw.GetString(Consts.DEVICENAME_KEY); device.Dirty = false; return device; }
public override ModelElement MakeCopy() { var device = new ModelDeviceSample(); CopyDataTo(device); return device; }
private bool IsDevicePresentProc(ModelDeviceSample deviceToCheck, ModelInterfaceSample parentInterface) { bool isPresent = false; var hwDetector = GenerateHardwareDetector(); if (hwDetector != null) { var availableDevices = hwDetector.GetConnectedInstruments(parentInterface); isPresent = deviceToCheck.IsDevicePresent(availableDevices); } return isPresent; }