public void SerialPortPing(Dictionary <int, KeyBoardCounter> dicCounterKeyboard) { if (serialPort.openPort()) { byte[] byteRes = modBus.BuildText(DEVICE_KEYBOARD, dicCounterKeyboard.Values.ToArray()[0].AddressKeyboard, (int)CheckByteSend.BYTE_COMMAND.STATUS_COMMAND, "", 1); serialPort.SendData(byteRes); } }
private static void InitKeyBoardSend(Dictionary <string, Counter> lstCounter, Dictionary <string, Service> lstServices) { dicCounter = lstCounter; dicService = lstServices; List <Counter> lstCounters = lstCounter.Values.ToList(); //var numDevice = InputAddressDevice(lstCounters); int address = 249; int numCounter = 1; string counterID = ""; do { counterID = dicCounter.Values.FirstOrDefault(m => m.CNum == numCounter).Id; if (!counterID.Equals("")) { dicCounterKeyboard.Add(address, new CounterAndKeyboard(counterID, address)); foreach (var counter in lstCounters) { serialPort.SendData(setSrcVcs.SetService(address, dicService.Select(m => m.Value.code).ToList())); serialPort.SendData(setSrcVcs.SetCounter(address, counter.Id, lstCounters.Select(m => m.Name).ToList())); } } } while (counterID.Equals("")); //for (int i = 0; i < numDevice; i++) //{ // Console.WriteLine("Thiet bi so: " + i + 1); // bool isCheck = false; // int address = -1; // int numCounter = -1; // do // { // Console.Write("Nhap dia chi: "); // isCheck = int.TryParse(Console.ReadLine(), out address); // }while(!isCheck); // isCheck = false; // do // { // Console.Write("Chon counter so: "); // isCheck = int.TryParse(Console.ReadLine(), out numCounter); // } while (!isCheck); // string counterID = ""; // do // { // counterID = dicCounter.Values.FirstOrDefault(m => m.CNum == numCounter).Id; // if (!counterID.Equals("")) // { // dicCounterKeyboard.Add(address, new CounterAndKeyboard(counterID, address)); // foreach (var counter in lstCounters) // { // serialPort.SendData(setSrcVcs.SetService(address, dicService.Select(m => m.Value.code).OrderBy(s=>s).ToList())); // serialPort.SendData(setSrcVcs.SetCounter(address, counter.Id, lstCounters.Select(m => m.Name).OrderBy(c => c).ToList())); // } // } // } while (counterID.Equals("")); //} log.sendLog("Set services and counter success!"); }