Beispiel #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                dispenser.SetConfiguration(tbDispPort.Text, Int32.Parse(tbDispBaudRate.Text), (Parity)Enum.Parse(typeof(Parity), tbDispParity.Text),
                                           Int32.Parse(tbDispBits.Text), (StopBits)Enum.Parse(typeof(StopBits), tbDispStopBits.Text));
                dispenser.Open();

                button6.Enabled  = true;
                button5.Enabled  = true;
                button9.Enabled  = true;
                button8.Enabled  = false;
                button21.Enabled = true;
            }
            catch
            {
                button6.Enabled  = false;
                button5.Enabled  = false;
                button9.Enabled  = false;
                button21.Enabled = false;
            }
        }
Beispiel #2
0
        private async Task LoadConfiguration(string fileName)
        {
            await Task.Run(async() =>
            {
                try
                {
                    Type t;
                    Assembly asm;
                    XmlDocument config = new XmlDocument();
                    config.Load(fileName);
                    XmlNodeList deviceConfig;

                    deviceConfig = config.SelectNodes(@"//device[@devicename='RFIDLib.RFID']");
                    asm          = Assembly.LoadFrom(deviceConfig[0].Attributes["libpath"].Value);
                    t            = asm.GetType(deviceConfig[0].Attributes["devicename"].Value, true, true);
                    rfidReader   = (ICardReader)Activator.CreateInstance(t);


                    rfidReader.SetConfiguration(deviceConfig[0].Attributes["port"].Value,
                                                Int32.Parse(deviceConfig[0].Attributes["boudrate"].Value),
                                                (Parity)Enum.Parse(typeof(Parity), deviceConfig[0].Attributes["parity"].Value),
                                                Int32.Parse(deviceConfig[0].Attributes["bits"].Value),
                                                (StopBits)Enum.Parse(typeof(StopBits), deviceConfig[0].Attributes["stopbits"].Value)
                                                );
                    rfidReader.Open();

                    deviceConfig = config.SelectNodes(@"//device[@devicename='RFIDLib.DispenserMT166']");
                    asm          = Assembly.LoadFrom(deviceConfig[0].Attributes["libpath"].Value);
                    t            = asm.GetType(deviceConfig[0].Attributes["devicename"].Value, true, true);
                    dispenser    = (IDispenser)Activator.CreateInstance(t);
                    dispenser.SetConfiguration(deviceConfig[0].Attributes["port"].Value,
                                               Int32.Parse(deviceConfig[0].Attributes["boudrate"].Value),
                                               (Parity)Enum.Parse(typeof(Parity), deviceConfig[0].Attributes["parity"].Value),
                                               Int32.Parse(deviceConfig[0].Attributes["bits"].Value),
                                               (StopBits)Enum.Parse(typeof(StopBits), deviceConfig[0].Attributes["stopbits"].Value)
                                               );

                    //  dispenser.Open();

                    deviceConfig  = config.SelectNodes(@"//device[@devicename='BillAcceptorUBA10_SS.BillAceptor']");
                    asm           = Assembly.LoadFrom(deviceConfig[0].Attributes["libpath"].Value);
                    t             = asm.GetType(deviceConfig[0].Attributes["devicename"].Value, true, true);
                    billValidator = (IBillValidator)Activator.CreateInstance(t);
                    billValidator.SetConfiguration(deviceConfig[0].Attributes["port"].Value,
                                                   Int32.Parse(deviceConfig[0].Attributes["boudrate"].Value),
                                                   (Parity)Enum.Parse(typeof(Parity), deviceConfig[0].Attributes["parity"].Value),
                                                   Int32.Parse(deviceConfig[0].Attributes["bits"].Value),
                                                   (StopBits)Enum.Parse(typeof(StopBits), deviceConfig[0].Attributes["stopbits"].Value)
                                                   );
                    billValidator.Open();
                    billValidator.BillAccept += Bill_BillAccept;
                    await billValidator.StartCommunication(cancelBillTokenSource);
                    ShowCurrentScreen(tpIdle);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    ShowInfo("АППАРАТ ВРЕМЕННО НЕ РАБОТАЕТ");
                }
            });
        }