Ejemplo n.º 1
0
        private string Subscribe(string[] items)
        {
            try
            {
                if (items.Length != 3)
                {
                    return("err,invalid command");
                }
                var lineId = Convert.ToInt32(items[1]);
                if (items[2] == "all")
                {
                    logger.LogDebug($"Subscribe all Labels on channel: {lineId}");
                    bool result = false;
                    for (byte label = 0; ; label++)
                    {
                        result = hardware.SubscribeA429Data(lineId, label);
                        if (label == 255)
                        {
                            break;
                        }
                    }
                    if (result)
                    {
                        return("ok");
                    }
                }
                else
                {
                    var label = Convert.ToByte(items[2], 8);
                    if (hardware.SubscribeA429Data(lineId, label))
                    {
                        return("ok");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogWarning($"Subscribe failed on channel: {Id} Error:{ex.Message}");
            }

            return("err");
        }