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

            return("err");
        }