public override void OnInputChange(Input input)
        {
            HardwareInput hardwareInput = (HardwareInput)input;

            Debug($"Hardware Node{hardwareInput.nodeId} Sensor{hardwareInput.sensorId} input: {input.Value}");

            gateway.SendSensorState(hardwareInput.nodeId, hardwareInput.sensorId, input.Value);
        }
        public override void OnInputChange(Input input)
        {
            string result;

            if (Inputs[0].Value == "0")
                result = "1";
            else
                result = "0";

            Debug($"Invert: from {Inputs[0].Value} to {result}");

            Outputs[0].Value = result;
        }
 public override void OnInputChange(Input input)
 {
     try
     {
         freqInput = Int32.Parse(input.Value);
         Debug($"Counter: frequency changed to {freqInput.Value} ms");
     }
     catch
     {
         freqInput = null;
         Debug($"Counter: frequency changed to default value: {DEFAULT_VALUE} ms");
     }
 }
        public override void OnInputChange(Input input)
        {
            int a = 0, b = 0;

            if (Inputs[0].Value != null)
                a = Int32.Parse(Inputs[0].Value);

            if (Inputs[1].Value != null)
                b = Int32.Parse(Inputs[1].Value);

            Debug($"MathPlus: {Inputs[0].Value} + {Inputs[1].Value}  = {Outputs[0].Value}");

            Outputs[0].Value = (a + b).ToString();
        }
Exemple #5
0
        public LogicalNode(int inputsCount, int outputsCount)
        {
            Id = Guid.NewGuid().ToString();

            Outputs = new List<Output>();
            for (int i = 0; i < outputsCount; i++)
            {
                Outputs.Add(new Output { Name = $"Out {i}" });
            }

            Inputs = new List<Input>();
            for (int i = 0; i < inputsCount; i++)
            {
                Input input = new Input { Name = $"In {i}" };
                Inputs.Add(input);
            }
        }
 public override void OnInputChange(Input input)
 {
 }
        public override void OnInputChange(Input input)
        {
            //Debug($"Console: {input.Value}");

            Console.WriteLine($"LOGICAL NODE CONSOLE: {input.Value}");
        }
        public void OnInputChange(Input input)
        {
            //DebugNodes($"Input changed: {input.Name}");

            if (!started)
                return;

            foreach (var node in nodes)
            {
                if (node.Inputs.Contains(input))
                    node.OnInputChange(input);
            }

            OnInputUpdatedEvent?.Invoke(input);
        }
 public LogicalLink GetLink(Output output, Input input)
 {
     return links.FirstOrDefault(x => x.InputId == input.Id && x.OutputId == output.Id);
 }
 public LogicalNode GetInputOwner(Input input)
 {
     foreach (var node in nodes)
     {
         if (node.Inputs.Contains(input))
             return node;
     }
     return null;
 }
        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;
        }
Exemple #13
0
 public abstract void OnInputChange(Input input);