Ejemplo n.º 1
0
 protected virtual void OnCommandQueueEmpty(SerialEventArgs info)
 {
     if (CommandQueueEmpty != null)
     {
         Task.Run(() => CommandQueueEmpty?.Invoke(this, info));
     }
 }
Ejemplo n.º 2
0
        private async Task InitServiceHub()
        {
            _serviceHub = new SerialServiceHub(WebServerUrl, this);
            var connection = await _serviceHub.Start();

            connection.On("queueEmpty", (int id) =>
            {
                if (PortId == id)
                {
                    CommandQueueEmpty?.Invoke(this, new SerialEventArgs());
                }
            });
            connection.On("queueChanged", (int id, int queuelength) =>
            {
                if (PortId == id)
                {
                    CommandQueueChanged?.Invoke(this, new SerialEventArgs(queuelength, null));
                }
            });
            connection.On("sendingCommand", (int id, int seqId) =>
            {
                if (PortId == id)
                {
                    CommandSending?.Invoke(this, new SerialEventArgs(new SerialCommand()
                    {
                        SeqId = seqId
                    }));
                }
            });
        }