public DriverAdapterBase(string name, bool idQuery, bool reset, string options) { DriverOptions = new Dictionary <string, string>(); IIviConfigStore ConfigStore = LoadConfigStore(); IviDriverSession CurrentDriver = ConfigStore.GetDriverSession(name); // Parse Options from Ivi driver setup ParseDriverOptions(DriverOptions, CurrentDriver.DriverSetup); // Parse Options from parameter ParseDriverOptions(DriverOptions, options); if (DriverOptions.ContainsKey("TargetName") && !DriverOptions["TargetName"].Equals(string.Empty)) { CurrentDriver = ConfigStore.GetDriverSession(DriverOptions["TargetName"]); } if (CurrentDriver.SoftwareModule == null) { new Exception(string.Format("Software Module not configured for driver session {0}", DriverOptions["TargetName"])); } TargetDriverName = CurrentDriver.Name; TargetDriverPrefix = CurrentDriver.SoftwareModule.Prefix; TargetLibraryFileName = CurrentDriver.SoftwareModule.ModulePath; string TargetSoftwareModuleName = CurrentDriver.SoftwareModuleName; string DriverSetup = CurrentDriver.DriverSetup; if (!Path.IsPathRooted(TargetLibraryFileName)) { string IviPath = (string)Registry.LocalMachine.OpenSubKey("SOFTWARE\\IVI").GetValue("IviStandardRootDir"); TargetLibraryFileName = Path.Combine(IviPath, "Bin\\" + TargetLibraryFileName); } LoadLibrary(); InitDynamicAssemblyBuilder(); DriverFunctionInterop(); interopClassType = typeBuilder.CreateType(); DriverInterop = (Adapter.IviCInterop.IviDriver)CreateInstanse(); ViSessionStatusCheck(DriverInterop.init(TargetDriverName, idQuery, reset, ref ViSession)); driverOperation = (IIviDriverOperation) new DriverOperation(this); identity = (IIviDriverIdentity) new DriverIdentity(this, TargetSoftwareModuleName); utility = (IIviDriverUtility) new DriverUtility(this); Marshal.ReleaseComObject(CurrentDriver); Marshal.ReleaseComObject(ConfigStore); }
public void DriverUtility() { IIviDriverUtility DriverUtility = Driver.Utility; DriverUtility.Reset(); DriverUtility.ResetWithDefaults(); ErrorQueryResult ErrorResult = DriverUtility.ErrorQuery(); Assert.AreEqual(0, ErrorResult.Code); Assert.AreEqual("No error.", ErrorResult.Message); SelfTestResult SelfTestResult = DriverUtility.SelfTest(); Assert.AreEqual(0, SelfTestResult.Code); Assert.AreEqual("Selftest passed", SelfTestResult.Message); IIviDriverLock DriverLock = DriverUtility.Lock(); DriverLock.Unlock(); DriverUtility.Disable(); }