Exemplo n.º 1
0
        public DacResponseDto Begin(ushort pointRate = 30000)
        {
            BeginCommandDto cmd = new BeginCommandDto()
            {
                Command = COMMAND_BEGIN,
                LowWaterMark = 0, //not implemented
                PointRate = pointRate
            };
            var serialized = Serialize<BeginCommandDto>(cmd);

            var response = Transmit(serialized);

            var ack = DacResponse.ParseAckCode(response.Response);

            return response;
        }
Exemplo n.º 2
0
        private void Heartbeat(object state)
        {

            if (!_socket.Connected && IsConnected)
            {
                DeviceDisconnected?.Invoke();
                IsConnected = false;
            }

            if (!IsConnected)
            {
                // Try reconnect
                try
                {
                    ConnectSocket();
                    DeviceConnected?.Invoke();

                }
                catch (Exception e)
                {
                    IsConnected = false;
                }
            }

            try
            {
                var response = Ping();

                Span<byte> statusSpan = Serialize<DacStatusDto>(response.DacStatus);

                var dacStatus = DacStatus.ParseDacStatus(statusSpan);

                var ack = DacResponse.ParseAckCode(response.Response);     

                StatusUpdated?.Invoke(ack, dacStatus.BufferFullness);
            }
            catch (Exception e)
            {

            }
        }