Beispiel #1
0
        public IOconfMap(string row, int lineNum) : base(row, lineNum, "Map")
        {
            format = "Map;SerialNo/COM1/USB1-1.1;BoxName;[NodeName];[baud rate]";

            var list = ToList();

            if (list[0] != "Map")
            {
                throw new Exception($"IOconfMap: wrong format: {row} {format}");
            }
            bool isWindows = RpiVersion.IsWindows();

            if (isWindows && list[1].StartsWith("COM"))
            {
                USBPort = list[1];
            }
            else if (!isWindows && list[1].StartsWith("USB"))
            {
                USBPort = "/dev/" + list[1];
            }
            else
            {
                SerialNumber = list[1];
            }

            BoxName = list[2];
            if (list.Count <= 3)
            {
                return;
            }

            string distributedNodeName = list.Count == 5 ? list[3] : default;
            var    baudrate            = 0;

            if (list.Count >= 5 && !int.TryParse(list[4], out baudrate))
            {
                CALog.LogErrorAndConsoleLn(LogID.A, $"Failed to parse the baud rate for the board: {BoxName}. Attempting with defaults.");
            }
            else if (list.Count == 4 && int.TryParse(list[3], out baudrate))
            {
                BaudRate = baudrate;
            }
            else
            {
                distributedNodeName = list[3];
            }

            BaudRate        = baudrate;
            DistributedNode = distributedNodeName != default
                ? IOconfFile.GetEntries <IOconfNode>().SingleOrDefault(n => n.Name == distributedNodeName) ?? throw new Exception($"Failed to find node in configuration for Map: {row}. Format: {format}")
                : !IOconfFile.GetEntries <IOconfNode>().Any() ? DistributedNode : throw new Exception($"The node name is not optional for distributed deployments: {row}. Format: {format}");
        }
Beispiel #2
0
        public IEnumerable <IOconfInput> GetDistributedExpandedInputConf()
        {
            if (Disabled)
            {
                yield break;
            }
            //note there is no map entry for the IOconfRpiTemp as it is not an external box, but at the moment we only expose the IOconfNode through it
            var nodes = IOconfFile.GetEntries <IOconfNode>().ToList();

            if (nodes.Count == 0)
            {
                var map = Map = new IOconfMap($"Map;RpiFakeBox;{Name}Box", LineNumber);
                yield return(new IOconfInput($"RPiTemp;{Name}Gpu", LineNumber, Type, false, false, BoardSettings.Default)
                {
                    Map = map, Skip = true
                });

                yield return(new IOconfInput($"RPiTemp;{Name}Cpu", LineNumber, Type, false, false, BoardSettings.Default)
                {
                    Map = map, Skip = true
                });

                yield break;
            }

            foreach (var node in nodes)
            {
                //note there is no map entry for the IOconfRpiTemp as it not an external box, but at the moment we only expose the IOconfNode through it
                var map = Map = new IOconfMap($"Map;RpiFakeBox;{Name}_{node.Name}Box;{node.Name}", LineNumber);
                yield return(new IOconfInput($"RPiTemp;{Name}_{node.Name}Gpu", LineNumber, Type, false, false, BoardSettings.Default)
                {
                    Map = map, Skip = true
                });

                yield return(new IOconfInput($"RPiTemp;{Name}_{node.Name}Cpu", LineNumber, Type, false, false, BoardSettings.Default)
                {
                    Map = map, Skip = true
                });
            }
        }