public LogicalNode GetOutputOwner(Output output)
 {
     foreach (var node in nodes)
     {
         if (node.Outputs.Contains(output))
             return node;
     }
     return null;
 }
        public void OnOutputChange(Output output)
        {
            if (!started)
                return;

            OnOutputUpdatedEvent?.Invoke(output);

            LogicalNode owner = GetOutputOwner(output);
            owner.OnOutputChange(output);

            List<LogicalLink> list = links.Where(x => x.OutputId == output.Id).ToList();

            foreach (var link in list)
            {
                Input input = GetInput(link.InputId);
                if (input != null)
                {
                    input.Value = output.Value;
                    OnInputUpdatedEvent?.Invoke(input);
                }
            }
        }
 public LogicalLink GetLink(Output output, Input input)
 {
     return links.FirstOrDefault(x => x.InputId == input.Id && x.OutputId == output.Id);
 }
        public void DeleteLink(Output output, Input input)
        {
            LogicalNode inputNode = GetInputOwner(input);
            LogicalNode outputNode = GetOutputOwner(output);
            DebugEngine($"Delete link from {outputNode.GetType().Name} to {inputNode.GetType().Name}");

            LogicalLink link = GetLink(output, input);

            OnLinkDeleteEvent?.Invoke(link);
            links.Remove(link);
        }
        public void AddLink(Output output, Input input)
        {
            LogicalNode inputNode = GetInputOwner(input);
            LogicalNode outputNode = GetOutputOwner(output);
            DebugEngine($"New link from {outputNode.GetType().Name} to {inputNode.GetType().Name}");

            LogicalLink link = new LogicalLink(output.Id, input.Id);
            links.Add(link);

            OnNewLinkEvent?.Invoke(link);

            if (!started)
                return;

            input.Value = output.Value;
        }
        public override void OnOutputChange(Output output)
        {
            HardwareOutput hardwareOutput = (HardwareOutput)output;

            Debug($"Hardware Node{hardwareOutput.nodeId} Sensor{hardwareOutput.sensorId} output: {output.Value}");
        }
Beispiel #7
0
 public virtual void OnOutputChange(Output output)
 {
 }