Exemplo n.º 1
0
 public CommandHandler(
     BillToBillDevice device, InterfaceCommand interfaceCommand,
     byte[] commandData) : base(device)
 {
     m_CommandData      = commandData;
     m_InterfaceCommand = interfaceCommand;
 }
Exemplo n.º 2
0
        /*public void Test()
         * {
         *
         * }*/

        public void LoadSettingsAndStart()
        {
            if (m_Initialized == true)
            {
                throw new InvalidOperationException("Already initialized");
            }

            string portName;
            var    deviceFound = BillToBillDevice.SearchDevice(out portName);

            if (deviceFound == true)
            {
                //var device = new BillToBillDevice(portName);
                if (OnSearchResult != null)
                {
                    OnSearchResult(this, new DeviceInfoEventArgs(portName));
                }
                Debug.Assert(portName != null, "portName != null");
                var deviceOpened = this.Open();
                Debug.Assert(deviceOpened == true, "deviceOpened == true");
                m_Initialized = true;

                PollDevice();
                //send reset command to device (transmit in initial state it)
                ResetDevice();
            }
            PollResponseCode pollState = PollResponseCode.None;
            var cycleCount             = 0;

            do
            {
                Thread.Sleep(CHECK_DEVICE_TRANSMIT_IN_DISABLED_STATE_INTERVAL_MSEC);
                //send poll command, check is device trmansmit in disabled state
                ResponsePoll pollResponse;
                PollDevice(out pollResponse);
                if (pollResponse.FirstCode == PollResponseCode.PowerUp)
                {
                    ResetDevice();
                    continue;
                }

                pollState = pollResponse.FirstCode;
                Debug.WriteLine(
                    string.Format(" Cycle - {0:X} ", cycleCount));
                cycleCount++;
            } while (cycleCount <=
                     ATTEMPTS_COUNT_WAIT_DEVICE_TRANSMIT_IN_DISABLED_STATE_AFTER_RESET &&
                     pollState != PollResponseCode.Unit_Disabled);
            if (cycleCount >
                ATTEMPTS_COUNT_WAIT_DEVICE_TRANSMIT_IN_DISABLED_STATE_AFTER_RESET)
            {
                throw new Exception("Device startup failed");
            }
            Debug.Assert(pollState == PollResponseCode.Unit_Disabled,
                         "pollState == PollResponseCode.Unit_Disabled");

            GetBillTable(out m_BillTable);
            m_ResyclingCassettes = new List <Cassette>(CreateCassettes()).ToArray();
            StartDevicePolling();
        }
Exemplo n.º 3
0
 public SetRecyclingCassetteTypeCmdHandler(
     BillToBillDevice device,
     byte cassetteNumber, byte billTypeId) :
     base(device, InterfaceCommand.Set_Recycling_Cassette_Type)
 {
     m_CassetteNumber = cassetteNumber;
     m_BillTypeId     = billTypeId;
 }
Exemplo n.º 4
0
        static bool CheckDeviceAvalibility(string portName)
        {
            bool deviceAvailable = false;

            Debug.Assert(portName != null, "portName != null");
            var device = new BillToBillDevice(portName);
            //try initialize device
            var deviceOpened = device.Open();

            if (deviceOpened == true)
            {
                //poll device
                //device successfully polled

                if (device.PollDevice() == true)
                {
                    deviceAvailable = true;
                }

                //close device
                device.Close();
            }
            return(deviceAvailable);
        }
Exemplo n.º 5
0
 public Cassette(byte cassetteNumber, BillToBillDevice device)
 {
     m_CassetteNumber = (byte)(cassetteNumber);
     m_Device         = device;
 }
Exemplo n.º 6
0
 public GetStatusCmdHandler(BillToBillDevice device) :
     base(device, InterfaceCommand.Get_Status, null)
 {
 }
Exemplo n.º 7
0
 public DispenseCmdHandler(BillToBillDevice device,
                           DispCmdItem[] dispCmdItems)
     : base(device, InterfaceCommand.Dispense)
 {
     m_DispCmdItems = dispCmdItems;
 }
Exemplo n.º 8
0
 public CmdHandlerWithoutRetData(BillToBillDevice device,
                                 InterfaceCommand interfaceCommand)
     : base(device)
 {
     m_InterfaceCommand = interfaceCommand;
 }
Exemplo n.º 9
0
 public PollCmdHandler(BillToBillDevice device,
                       InterfaceCommand command, byte[] commandData) : base(
         device, command, commandData)
 {
 }
Exemplo n.º 10
0
 public CommandHandlerBase(BillToBillDevice device)
 {
     m_Device = device;
 }
Exemplo n.º 11
0
 //readonly GetBillTableResponse m_GetBillTableResponse;
 public GetRecyclingCasseteStatusCmdHandler(
     BillToBillDevice device) :
     base(device, InterfaceCommand.Recycling_Cassette_Status, null)
 {
 }
Exemplo n.º 12
0
 public GetBillTableCmdHandler(BillToBillDevice device) :
     base(device, InterfaceCommand.GetBillTable, null)
 {
 }