Ejemplo n.º 1
0
        public IHttpActionResult Open()
        {
            ICardReader cardReader = ContextManager.GetCardReader();
            bool        ret        = false;

            if (cardReader != null)
            {
                ret = cardReader.Open();
            }

            return(Json <ResultArgs>(
                       new ResultArgs(ret)
            {
                Result = "open card reader",
                Msg = ret ? "OK" : "failed"
            }));
        }
Ejemplo n.º 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                SerialPort port = new SerialPort(tbPort.Text, Int32.Parse(tbBoudRate.Text), (Parity)Enum.Parse(typeof(Parity), tbParity.Text),
                                                 Int32.Parse(tbBits.Text), (StopBits)Enum.Parse(typeof(StopBits), tbStopBits.Text));

                rfidReader.SetConfiguration(port);
                rfidReader.Open();
                button3.Enabled  = true;
                button4.Enabled  = true;
                button10.Enabled = true;
                button1.Enabled  = false;
            }
            catch
            {
                button3.Enabled  = false;
                button4.Enabled  = false;
                button10.Enabled = false;
            }
        }
Ejemplo n.º 3
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("АППАРАТ ВРЕМЕННО НЕ РАБОТАЕТ");
                }
            });
        }