Пример #1
0
 public void OpenPort(int portNum, int baudRate)
 {
     MHelper.WriteLog("Библиотека для РРО КБМ Групп" + "(Версия 1.0.0.3). 27 февраля 2017 года.");
     if (baudRate == 9600 || baudRate == 19200 || baudRate == 57600 || baudRate == 115200)
     {
         _datecsPort = Datecs.GetDatecsPrinterPort(portNum, baudRate);
     }
     else
     {
         ErrorPropertiesUpdate("Неверная скорость СОМ порта,  будет установлена 115200", 1);
         _datecsPort = Datecs.GetDatecsPrinterPort(portNum, 115200);
     }
     _datecsPort.EventHandlersAddRemove(UpdateDataEventHandler, ErrorPropertiesEventHandler, ErrorPropertiesEventHandler);
     _datecsPort.EventHandlersAddRemove(MHelper.DataUpdateHandler,
                                        MHelper.ErrorHandler, MHelper.StatusUpdateHandler);
     if (_datecsPort.PortOpen())
     {
         MHelper.WriteLog("Port COM" + portNum + " is opened");
         _datecsPort.SendCommand(Commands.DiagnosticInfo);
         if (s6.Length == 10)
         {
             if (!s6.StartsWith("КБ") && !s6.StartsWith("БМ"))
             {
                 ErrorPropertiesUpdate("Ошибка лицензии. Заводской номер должен начинаться с КБ или БМ.", 8);
                 ClosePort();
             }
         }
     }
 }