コード例 #1
0
        private ModelInterfaceSample ConstructInterface(XElement intfcElement)
        {
            ModelInterfaceSample intfc = null;
            var connectionTimeoutAttr = intfcElement.Attribute(Consts.CONNECTION_TIMEOUT_ATTR);
            var busAddressAttr = intfcElement.Attribute(Consts.BUS_ADDRESS_ATTR);
            var visaNameAttr = intfcElement.Attribute(Consts.VISA_NAME_ATTR);
            var siclNameAttr = intfcElement.Attribute(Consts.SICL_NAME_ATTR);
            var luAttr = intfcElement.Attribute(Consts.LU_ATTR);
            var autoDiscoverAttr = intfcElement.Attribute(Consts.AUTO_DISCOVER);
            if (connectionTimeoutAttr != null
                && busAddressAttr != null
                && visaNameAttr != null
                && siclNameAttr != null
                && luAttr != null)
            {
                int connectionTimeout, busAddress, lu;
                intfc = new ModelInterfaceSample();
                intfc.VisaInterfaceId = visaNameAttr.Value;
                intfc.SiclInterfaceId = siclNameAttr.Value;
                intfc.ConnectionTimeout = int.TryParse(connectionTimeoutAttr.Value, out connectionTimeout) ? connectionTimeout : 5000;
                intfc.BusAddress = int.TryParse(busAddressAttr.Value, out busAddress) ? busAddress : 0;
                intfc.LogicalUnit = int.TryParse(luAttr.Value, out lu) ? luAttr.Value : "100";

                bool autoDiscover = false;
                autoDiscover = autoDiscoverAttr != null && bool.TryParse(autoDiscoverAttr.Value, out autoDiscover) ? autoDiscover : false;
                intfc.AutoDiscoverDevices = autoDiscover;
            }
            return intfc;
        }
コード例 #2
0
        public override ModelElement MakeCopy()
        {
            var intfc = new ModelInterfaceSample();

            CopyDataTo(intfc);
            return(intfc);
        }
コード例 #3
0
 public IEnumerable<ModelDeviceSample> GetConnectedInstruments(ModelInterfaceSample intfc)
 {
     var availableInstruments = Enumerable.Empty<ModelDeviceSample>();
     Monitor.Enter(_modelList);
     availableInstruments = _modelList.Where(e => e is ModelDeviceSample && ((ModelDeviceSample)e).Parent.IsEquivalent(intfc))
         .Select(e => (ModelDeviceSample)e);
     Monitor.Exit(_modelList);
     return availableInstruments;
 }
コード例 #4
0
 public IEnumerable<ModelDeviceSample> GetConnectedInstruments(ModelInterfaceSample intfc)
 {
     var availableInstruments = Enumerable.Empty<ModelDeviceSample>();
     Monitor.Enter(_modelList);
     availableInstruments = _modelList.Where(e => e is ModelDeviceSample && ((ModelDeviceSample)e).Parent.IsEquivalent(intfc))
         .Select(e => (ModelDeviceSample)e);
     Monitor.Exit(_modelList);
     return availableInstruments;
 }
コード例 #5
0
        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);
        }
コード例 #6
0
 private void VerfiyInterface(ModelInterfaceSample intfc)
 {
     ModelInterface[] availableInterfaces = GetAvailableInterfaces();
     if (IsInterfacePresentProc(intfc, availableInterfaces) ||
         intfc.StaticallyDefined)
     {
         intfc.Verified = true;
         intfc.Failed   = false;
     }
     else
     {
         intfc.FailedReason = AgentKeys.FailedReason_InterfaceNotPresent;
     }
 }
コード例 #7
0
        public static bool IsInterfacePresent(this ModelInterfaceSample interfaceToCheck, IEnumerable <ModelInterface> availableInterfaces)
        {
            bool isPresent = false;

            foreach (var availableInterface in availableInterfaces)
            {
                var specificInterface = availableInterface as ModelInterfaceSample;
                if (specificInterface != null &&
                    specificInterface.IsEquivalent(interfaceToCheck))
                {
                    isPresent = true;
                    break;
                }
            }
            return(isPresent);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        public ModelInterface ReconstituteInterface(InterfaceDataRecord raw)
        {
            if (raw == null)
            {
                return(null);
            }
            if (!CanReconstituteThis(raw))
            {
                return(null);
            }

            var intfc = new ModelInterfaceSample();

            ExtractCommonInterfacePropertiesFromNVPairs(raw, intfc);
            intfc.ConnectionTimeout = raw.GetInt(Consts.CONNECTION_TIMEOUT_KEY);
            intfc.BusAddress        = raw.GetInt(Consts.BUS_ADDRESS_KEY);
            intfc.Dirty             = false;

            return(intfc);
        }
コード例 #11
0
 private static void AddInfoToInterface(InterfaceDataRecord raw, ModelInterfaceSample specificIntfc)
 {
     raw.AddProperty(Consts.CONNECTION_TIMEOUT_KEY, specificIntfc.ConnectionTimeout.ToString());
     raw.AddProperty(Consts.BUS_ADDRESS_KEY, specificIntfc.BusAddress.ToString());
 }
コード例 #12
0
        private void FindAndUpdateDevices(IConfigDll hwconfig, List <ModelElement> discoveredList, ModelInterfaceSample intfc, AceModelRestricted model)
        {
            var connectedDevices = hwconfig.GetAvailableDevices(intfc);

            discoveredList.AddRange(connectedDevices);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 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;
 }
コード例 #15
0
        public ModelInterface ReconstituteInterface(InterfaceDataRecord raw)
        {
            if (raw == null) return null;
            if (!CanReconstituteThis(raw)) return null;

            var intfc = new ModelInterfaceSample();
            ExtractCommonInterfacePropertiesFromNVPairs(raw, intfc);
            intfc.ConnectionTimeout = raw.GetInt(Consts.CONNECTION_TIMEOUT_KEY);
            intfc.BusAddress = raw.GetInt(Consts.BUS_ADDRESS_KEY);
            intfc.Dirty = false;

            return intfc;
        }
コード例 #16
0
 private static void AddInfoToInterface(InterfaceDataRecord raw, ModelInterfaceSample specificIntfc)
 {
     raw.AddProperty(Consts.CONNECTION_TIMEOUT_KEY, specificIntfc.ConnectionTimeout.ToString());
     raw.AddProperty(Consts.BUS_ADDRESS_KEY, specificIntfc.BusAddress.ToString());
 }
コード例 #17
0
 private static ModelInterfaceSample GenerateSampleInterface(string visaID, string siclID, string lu, bool staticDefailed = false)
 {
     var sampleInterface = new ModelInterfaceSample();
     sampleInterface.VisaInterfaceId = visaID;
     sampleInterface.SiclInterfaceId = siclID;
     sampleInterface.LogicalUnit = lu;
     sampleInterface.StaticallyDefined = staticDefailed;
     return sampleInterface;
 }
コード例 #18
0
        public void GetAddingElementSingleInterfaceTest()
        {
            var sampleInterface = new ModelInterfaceSample();
            sampleInterface.VisaInterfaceId = "SAMP0";
            sampleInterface.SiclInterfaceId = "samp";
            sampleInterface.LogicalUnit = "100";
            var model = GenerateModel(sampleInterface);
            var intfc = GenerateNewSampleInterface(model);

            Assert.IsNotNull(intfc);
            Assert.IsTrue(intfc.VisaInterfaceId == "SAMP1");
            Assert.IsTrue(intfc.SiclInterfaceId == "samp1");
            Assert.IsTrue(intfc.LogicalUnit == "101");
        }
コード例 #19
0
        public void GetAddingElementMultipleInterfaceTest()
        {
            var sampleInterface1 = new ModelInterfaceSample();
            sampleInterface1.VisaInterfaceId = "SAMP0";
            sampleInterface1.SiclInterfaceId = "samp";
            sampleInterface1.LogicalUnit = "100";
            var sampleInterface2 = new ModelInterfaceSample();
            sampleInterface2.VisaInterfaceId = "SAMP1";
            sampleInterface2.SiclInterfaceId = "samp1";
            sampleInterface2.LogicalUnit = "101";

            var model = GenerateModel(sampleInterface1, sampleInterface2);
            var intfc = GenerateNewSampleInterface(model);

            Assert.IsNotNull(intfc);
            Assert.IsTrue(intfc.VisaInterfaceId == "SAMP2");
            Assert.IsTrue(intfc.SiclInterfaceId == "samp2");
            Assert.IsTrue(intfc.LogicalUnit == "102");
        }
コード例 #20
0
 public override ModelElement MakeCopy()
 {
     var intfc = new ModelInterfaceSample();
     CopyDataTo(intfc);
     return intfc;
 }
コード例 #21
0
        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;
        }
コード例 #22
0
 private void VerfiyInterface(ModelInterfaceSample intfc)
 {
     ModelInterface[] availableInterfaces = GetAvailableInterfaces();
     if (IsInterfacePresentProc(intfc, availableInterfaces)
         || intfc.StaticallyDefined)
     {
         intfc.Verified = true;
         intfc.Failed = false;
     }
     else
     {
         intfc.FailedReason = AgentKeys.FailedReason_InterfaceNotPresent;
     }
 }
コード例 #23
0
 private bool IsInterfacePresentProc(ModelInterfaceSample interfaceToCheck, ModelInterface[] availableInterfaces)
 {
     return(interfaceToCheck.IsInterfacePresent(availableInterfaces));
 }
コード例 #24
0
        public void VerifyElementTestInterface()
        {
            var intfc1 = new ModelInterfaceSample { VisaInterfaceId = "SAMP0", SiclInterfaceId = "samp", LogicalUnit = "100" };
            var hwconfig1 = GenerateHwConfig();
            hwconfig1.VerifyElement(intfc1);
            Assert.IsTrue(!intfc1.Failed);
            Assert.IsTrue(intfc1.Verified);

            var intfc2 = new ModelInterfaceSample { VisaInterfaceId = "SAMP1", SiclInterfaceId = "samp1", LogicalUnit = "101" };
            var hwconfig2 = GenerateHwConfig();
            hwconfig2.VerifyElement(intfc2);
            Assert.IsTrue(intfc2.Failed);
            Assert.IsTrue(!intfc2.Verified);
        }
コード例 #25
0
 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;
 }
コード例 #26
0
 private void FindAndUpdateDevices(IConfigDll hwconfig, List<ModelElement> discoveredList, ModelInterfaceSample intfc, AceModelRestricted model)
 {
     var connectedDevices = hwconfig.GetAvailableDevices(intfc);
     discoveredList.AddRange(connectedDevices);
 }
コード例 #27
0
        private ModelInterfaceSample ConstructInterface(XElement intfcElement)
        {
            ModelInterfaceSample intfc = null;
            var connectionTimeoutAttr = intfcElement.Attribute(Consts.CONNECTION_TIMEOUT_ATTR);
            var busAddressAttr = intfcElement.Attribute(Consts.BUS_ADDRESS_ATTR);
            var visaNameAttr = intfcElement.Attribute(Consts.VISA_NAME_ATTR);
            var siclNameAttr = intfcElement.Attribute(Consts.SICL_NAME_ATTR);
            var luAttr = intfcElement.Attribute(Consts.LU_ATTR);
            var autoDiscoverAttr = intfcElement.Attribute(Consts.AUTO_DISCOVER);
            if (connectionTimeoutAttr != null
                && busAddressAttr != null
                && visaNameAttr != null
                && siclNameAttr != null
                && luAttr != null)
            {
                int connectionTimeout, busAddress, lu;
                intfc = new ModelInterfaceSample();
                intfc.VisaInterfaceId = visaNameAttr.Value;
                intfc.SiclInterfaceId = siclNameAttr.Value;
                intfc.ConnectionTimeout = int.TryParse(connectionTimeoutAttr.Value, out connectionTimeout) ? connectionTimeout : 5000;
                intfc.BusAddress = int.TryParse(busAddressAttr.Value, out busAddress) ? busAddress : 0;
                intfc.LogicalUnit = int.TryParse(luAttr.Value, out lu) ? luAttr.Value : "100";

                bool autoDiscover = false;
                autoDiscover = autoDiscoverAttr != null && bool.TryParse(autoDiscoverAttr.Value, out autoDiscover) ? autoDiscover : false;
                intfc.AutoDiscoverDevices = autoDiscover;
            }
            return intfc;
        }
コード例 #28
0
 private bool IsInterfacePresentProc(ModelInterfaceSample interfaceToCheck, ModelInterface[] availableInterfaces)
 {
     return interfaceToCheck.IsInterfacePresent(availableInterfaces);
 }