Exemple #1
0
    public ChannelSystem(ChannelSystem parent, List <Channel> channels)
    {
        this.parent   = parent;
        this.channels = channels;

        this.channelsByName   = channels.ToDictionary(channel => channel.Name, channel => channel);
        this.channelEvaluator = new ChannelEvaluator(channels);
        this.defaultOutputs   = Evaluate(parent?.defaultOutputs, MakeDefaultChannelInputs());
    }
Exemple #2
0
    public void TestRawValue()
    {
        Channel        channel  = new Channel("foo", 0, null, 0, 0, 0, false, false, null);
        List <Channel> channels = new List <Channel> {
            channel
        };
        var evaluator = new ChannelEvaluator(channels);
        var inputs    = new ChannelInputs(new double[] { 42 });
        var outputs   = evaluator.Evaluate(null, inputs);

        Assert.AreEqual(42, outputs.Values[0], Acc);
    }
Exemple #3
0
    private void AssertFormulaEquals(double expectedResult, Formula formula)
    {
        Channel channel = new Channel("foo", 0, null, 0, 0, 0, false, false, null);

        channel.AttachSumFormula(formula);
        List <Channel> channels = new List <Channel> {
            channel
        };
        var evaluator = new ChannelEvaluator(channels);
        var inputs    = new ChannelInputs(new double[] { 0 });
        var outputs   = evaluator.Evaluate(null, inputs);

        Assert.AreEqual(expectedResult, outputs.Values[0], Acc);
    }
Exemple #4
0
    public void TestPushChannel()
    {
        Channel channel0 = new Channel("foo", 0, null, 0, 0, 0, false, false, null);
        Channel channel1 = new Channel("bar", 1, null, 0, 0, 0, false, false, null);

        channel0.AttachSumFormula(new Formula(new IOperation[] {
            new PushChannelOperation(channel1)
        }));

        List <Channel> channels = new List <Channel> {
            channel0, channel1
        };

        var evaluator = new ChannelEvaluator(channels);
        var inputs    = new ChannelInputs(new double[] { 0, 42 });
        var outputs   = evaluator.Evaluate(null, inputs);

        Assert.AreEqual(42, outputs.Values[0], Acc);
    }