Esempio n. 1
0
        private void btnStartCharge_Click(object sender, RoutedEventArgs e)
        {
            //var charge = txtyishou.Text.Todecimal();
            var charge = cmbcharge.Text.Todecimal();

            DeviceBus.StartCharge(charge);
        }
Esempio n. 2
0
        protected override void ShowItemInGridViewRow(DataGridViewRow row, object item)
        {
            DeviceBus ct = item as DeviceBus;

            row.Cells["colID"].Value      = ct.ID;
            row.Cells["colName"].Value    = ct.Name;
            row.Cells["colComport"].Value = "COM" + ct.Comport.ToString();
            row.Cells["colBaud"].Value    = ct.Baud;
        }
Esempio n. 3
0
        private void btnICOpenPort_Click(object sender, RoutedEventArgs e)
        {
            var msg = DeviceBus.Init("COM1", "COM2", "COM3", "COM4", "COM5", "COM6");

            if (string.IsNullOrEmpty(msg) == false)
            {
                Core.Log.In(msg);
            }
            else
            {
                Core.Log.In("初始化成功");
                //btnBus.IsEnabled = true;
                //btnStopReceive.IsEnabled = true;
            }
            btnBus.IsEnabled                = true;
            btnStopReceive.IsEnabled        = true;
            DeviceBus.OnAcceptMoneyWithAll += (s, currentMoney, total) =>
            {
                //m 应收
                //t 实收
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    txtCurrentMoney.Text = currentMoney.ToString();
                    txtTotalMoney.Text   = total.ToString();
                }));
            };

            DeviceBus.OnChargeOver += (x, agg, unChargeMoney) =>
            {
                if (unChargeMoney == 0)
                {
                    var m100 = agg[ChargeMoneyType.M100];
                    Core.Log.In("100找零->" + m100);

                    var m50 = agg[ChargeMoneyType.M50];
                    Core.Log.In("50找零->" + m50);

                    var m5 = agg[ChargeMoneyType.M5];
                    Core.Log.In("5找零->" + m5);

                    var m1 = agg[ChargeMoneyType.M1];
                    Core.Log.In("1找零->" + m1);
                }
                else
                {
                    Core.Log.In("未找零金额->" + unChargeMoney);
                }
            };

            DeviceBus.OnReadCardNo += (s, no) =>
            {
                Core.Log.In(no);
            };
        }
        protected override void ItemShowing()
        {
            DeviceBus ct = UpdatingItem as DeviceBus;

            txtID.Text    = ct.ID;
            txtID.Enabled = false;
            txtName.Text  = ct.Name;

            cmbCommport.ComPort = (byte)ct.Comport;
            cmbBaud.Text        = ct.Baud.ToString();
        }
Esempio n. 5
0
 private void btnAllTest_click(object sender, RoutedEventArgs e)
 {
     try
     {
         txtCurrentMoney.Text = "0";
         txtTotalMoney.Text   = "0";
         DeviceBus.StartReceiveMoney(txtNeed.Text.Todecimal());
     }
     catch (Exception ex)
     {
         Core.Log.Out("异常1->" + ex.Message);
     }
 }
 protected override Object GetItemFromInput()
 {
     DeviceBus ct = UpdatingItem as DeviceBus ;
     if (IsAdding)
     {
         ct = new DeviceBus();
         ct.ID = txtID.Text != "自动创建" ? txtID.Text : string.Empty;
     }
     ct.Name = txtName.Text;
     ct.Comport = cmbCommport.ComPort;
     ct.Baud = int.Parse(cmbBaud.Text);
     return ct;
 }
        protected override Object GetItemFromInput()
        {
            DeviceBus ct = UpdatingItem as DeviceBus;

            if (IsAdding)
            {
                ct    = new DeviceBus();
                ct.ID = txtID.Text != "自动创建" ? txtID.Text : string.Empty;
            }
            ct.Name    = txtName.Text;
            ct.Comport = cmbCommport.ComPort;
            ct.Baud    = int.Parse(cmbBaud.Text);
            return(ct);
        }
Esempio n. 8
0
            /// <summary>
            ///     Scan the specified device bus for OneWire devices.
            /// </summary>
            /// <remarks>
            ///     The OneWire protocol allows for multiple OneWire devices to be
            ///     attached to the same pin.  This method identifies all of the devices
            ///     that are connected to the pin used to create this object.
            /// </remarks>
            private void ScanForDevices()
            {
                ArrayList deviceList;

                lock (DeviceBus)
                {
                    DeviceBus.TouchReset();
                    deviceList = DeviceBus.FindAllDevices();
                }

                for (var device = 0; device < deviceList.Count; device++)
                {
                    UInt64 deviceID      = 0;
                    byte[] deviceIDArray = ((byte[])deviceList[device]);
                    for (var index = 0; index < 8; index++)
                    {
                        int  places = 8 * index;
                        byte value  = deviceIDArray[index];
                        deviceID |= ((UInt64)value) << places;
                    }

                    DeviceIDs.Add(deviceID);
                }
            }
Esempio n. 9
0
 private void btnStopReadCard_Click(object sender, RoutedEventArgs e)
 {
     DeviceBus.StopReadCard();
 }
Esempio n. 10
0
 private void btnStop_Click(object sender, RoutedEventArgs e)
 {
     DeviceBus.StopReceiveMoney();
 }
Esempio n. 11
0
 private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     DeviceBus.UnInit();
 }