Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     DriverInterop = null;
     UnloadLibrary();
 }