Пример #1
0
        private void InitalizeDevice()
        {
            if (this.IsHandleCreated)
            {
                MethodInvoker mi = () =>
                {
                    this.ApplicationpicBoxWait.Enabled = false;
                    this.ApplicationpicBoxWait.Visible = false;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(mi);
                }
                else
                {
                    Invoke(mi);
                }
            }

            try
            {
                devicePlugin = new IPA.DAL.RBADAL.DeviceCfg() as IDevicePlugIn;
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    try
                    {
                        // Initialize Device
                        devicePlugin.OnDeviceNotification += new EventHandler <DeviceNotificationEventArgs>(this.OnDeviceNotificationUI);
                        devicePlugin.DeviceInit();
                        Debug.WriteLine("main: loaded plugin={0} ++++++++++++++++++++++++++++++++++++++++++++", (object)devicePlugin.PluginName);
                    }
                    catch (Exception ex)
                    {
                        Logger.error("main: exception={0}", (object)ex.Message);
                        if (ex.Message.Equals("NoDevice"))
                        {
                            WaitForDeviceToConnect();
                        }
                        else if (ex.Message.Equals("MultipleDevice"))
                        {
                            this.Invoke(new MethodInvoker(() =>
                            {
                                MessageBoxEx.Show(this, "Multiple Devices Detected\r\nDisconnect One of them !!!", "ERROR: MULTIPLE DEVICES DETECTED", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                WaitForDeviceToConnect();
                            }));
                        }
                    }
                }).Start();
            }
            catch (Exception exp)
            {
                Logger.error("main: Initalize() - exception={0}", (object)exp.Message);
            }
        }
Пример #2
0
 public static void SetDeviceConfig(IDevicePlugIn devicePlugin, object payload)
 {
     try
     {
         // Make call to DeviceCfg
         devicePlugin.SetDeviceConfiguration(payload);
     }
     catch (Exception exp)
     {
         Debug.WriteLine("main: SetDeviceConfiguration() - exception={0}", (object)exp.Message);
     }
 }
Пример #3
0
        public IDevicePlugIn InstantiatePlugin(string dllName, AppDomain domain)
        {
            IDevicePlugIn plugIn = null;

            string PLUGIN_NAME = " AugustaHIDCfg." + dllName + ".DeviceCfg";

            try
            {
                plugIn = domain.CreateInstanceAndUnwrap(dllName, PLUGIN_NAME) as IDevicePlugIn;
            }
            catch (Exception e)
            {
                Debug.WriteLine("InsantiatePlugin: exception={0}", (object)e.Message);
            }

            return(plugIn);
        }
Пример #4
0
        public IDevicePlugIn InstantiatePlugin(AppDomain domain, string ASSEMBLY_NAME, string PLUGIN_NAME)
        {
            Debug.WriteLine("main: assembly fullname is=[{0}].", (object)ASSEMBLY_NAME);

            IDevicePlugIn plugIn = null;

            try
            {
                plugIn = domain.CreateInstanceAndUnwrap(ASSEMBLY_NAME, PLUGIN_NAME) as IDevicePlugIn;
            }
            catch (Exception e)
            {
                Debug.WriteLine("InsantiatePlugin: exception={0}", (object)e.Message);
            }

            return(plugIn);
        }
Пример #5
0
        public void TestIfUnloaded(IDevicePlugIn plugin)
        {
            bool unloaded = false;

            try
            {
                Debug.WriteLine(plugin.PluginName);
            }
            catch (AppDomainUnloadedException)
            {
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (!unloaded)
            {
                Debug.WriteLine("It does not appear that the app domain successfully unloaded.");
            }
        }
Пример #6
0
        private void InitalizeDevice(bool unload = false)
        {
            // Unload Domain
            if (unload && appDomainCfg != null)
            {
                appDomainCfg.UnloadPlugin(appDomainDevice);

                // Test Unload
                appDomainCfg.TestIfUnloaded(devicePlugin);
            }

            appDomainCfg = new AppDomainCfg();

            // AppDomain Interface
            appDomainDevice = appDomainCfg.CreateAppDomain(MODULE_NAME);

            // Load Interface
            devicePlugin = appDomainCfg.InstantiatePlugin(MODULE_NAME, appDomainDevice);

            // Initialize interface
            if (devicePlugin != null)
            {
                // Disable Tab(s)
                this.tabPage1.Enabled = false;
                this.tabPage2.Enabled = false;
                this.tabPage3.Enabled = false;
                this.tabPage4.Enabled = false;

                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    Debug.WriteLine("\nmain: new device detected! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

                    // Setup DeviceCfg Event Handlers
                    devicePlugin.initializeDevice         += new DeviceEventHandler(this.InitalizeDeviceUI);
                    devicePlugin.unloadDeviceconfigDomain += new DeviceEventHandler(this.UnloadDeviceConfigurationDomain);
                    devicePlugin.processCardData          += new DeviceEventHandler(this.ProcessCardDataUI);
                    devicePlugin.processCardDataError     += new DeviceEventHandler(this.ProcessCardDataErrorUI);
                    devicePlugin.getDeviceConfiguration   += new DeviceEventHandler(this.GetDeviceConfigurationUI);
                    devicePlugin.setDeviceConfiguration   += new DeviceEventHandler(this.SetDeviceConfigurationUI);
                    devicePlugin.setDeviceMode            += new DeviceEventHandler(this.SetDeviceModeUI);
                    devicePlugin.setExecuteResult         += new DeviceEventHandler(this.SetExecuteResultUI);
                    devicePlugin.showJsonConfig           += new DeviceEventHandler(this.ShowJsonConfigUI);

                    if (tc_show_json_tab && dev_usb_mode == DEV_USB_MODE.USB_HID_MODE)
                    {
                        this.Invoke(new MethodInvoker(() =>
                        {
                            this.picBoxJsonWait.Visible = true;
                            tabControl1.SelectedTab     = this.tabPage5;
                        }));
                    }

                    // Initialize Device
                    devicePlugin.DeviceInit(new AppConfigWrapper());
                    Debug.WriteLine("main: loaded plugin={0} ++++++++++++++++++++++++++++++++++++++++++++", (object)devicePlugin.PluginName);

                    UpdateUI();
                }).Start();
            }
        }