Exemplo n.º 1
0
        /// <summary>
        /// Recursively go through each Node of a circuit and call the Execute Action of each node
        /// </summary>
        /// <param name="startingNodeId"></param>
        /// <param name="previousPinId"></param>
        public static void StepThroughCircuit(int startingNodeId, int?previousPinId = null)
        {
            if (!CircuitTable.Any())
            {
                throw new Exception("CircuitTable not initialized");
            }

            Node fromNode = NodeTable[startingNodeId];

            // Call the node logic
            fromNode.ExecuteAction(out bool passPower);

            foreach (Pin fromPin in fromNode.Pins.Where(x => x.PinId != previousPinId))
            {
                if (fromPin.ToPinId.HasValue)
                {
                    int toPinId = fromPin.ToPinId.Value;

                    // TODO pass voltage through Nodes / through the ExecuteActions???
                    // ArrowTable.Add(new Arrow(fromPin.PinId, toPinId, CalculateVoltage, CalculateAmps));

                    Pin toPin = PinTable[toPinId];

                    if (passPower)
                    {
                        toPin.On();
                    }

                    int toPinParentNodeId = toPin.ParentNodeId;

                    StepThroughCircuit(toPinParentNodeId, toPinId);
                }
            }
            // exit (no more nodes to traverse)
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the load items command.
        /// </summary>
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                _circuits = await App.RestService.GetCircuitsAsync();

                _circuits.Circuits = _circuits.Circuits.OrderBy(o => o.Name).ToList();
                LoadItemsFromData();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 3
0
 public CircuitController()
 {
     profileTable         = new LocationProfileTable();
     HardwareModel        = new HardwareTable();
     locationTable        = new LocationTable();
     circuitTable         = new CircuitTable();
     circuitLocationTable = new CircuitLocationTable();
 }
Exemplo n.º 4
0
 public MonitorController()
 {
     locationTable = new LocationTable();
     // _fieldsTable = new CustomFieldsTable("LocationCustomFields");
     _processesTable = new ProcessesTable();
     _diagramTable   = new DiagramTable();
     _circuitTable   = new CircuitTable();
     _usertable      = new UserTable();
     _monitorTable   = new ObjectRealMonitorTable();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Populates the Circuit, Node and Pin tables
 /// </summary>
 /// <param name="circuit"></param>
 public static void RegisterCircuit(Circuit circuit)
 {
     CircuitTable.Add(circuit.CircuitId, circuit);
     foreach (Node node in circuit.Nodes)
     {
         NodeTable.Add(node.NodeId, node);
         foreach (Pin pin in node.Pins)
         {
             PinTable.Add(pin.PinId, pin);
         }
     }
 }