Exemplo n.º 1
0
        public void StartDevice(DeviceInfo device)
        {
            //Записываю Кодограмму
            RG_ENDPOINT  portEndpoin = device.Endpoint;
            RG_CODOGRAMM codogram    = new RG_CODOGRAMM {
                Length = 32,
                Body   = 0x00000000
            };
            byte codogramNumber = 1;
            uint errorCode      = RG_WriteCodogramm(ref portEndpoin, device.DeviceInfoShort.DeviceAddress, codogramNumber, ref codogram);

            if (errorCode != 0)
            {
                throw new ApplicationException($"Ошибка при записи кодограммы = {errorCode}");
            }
        }
Exemplo n.º 2
0
 private void WriteCodogramm(CodogrammData data)
 {
     try {
         RG_ENDPOINT  portEndpoin = _currentConnectoinContext.ReaderPort;
         byte         address     = _currentConnectoinContext.ReaderAddress;
         RG_CODOGRAMM codogram    = new RG_CODOGRAMM {
             Length = data.LengthBits,
             Body   = data.CodogrammBody
         };
         uint errorCode = UnmanagedContext.Instance.RG_WriteCodogramm(ref portEndpoin, address, data.Number, ref codogram);
         if (errorCode != 0)
         {
             throw new ApiCallException("Ошибка при записи кодограммы", errorCode);
         }
     }
     catch (Exception ex) {
         MessageBox.Show(this,
                         string.Format("({1}) {0}", ex.Message,
                                       (ex is ApiCallException) ? (ex as ApiCallException).ApiCallErrorCode.ToString() : "..."),
                         "Ошибка",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }