Beispiel #1
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsChanged || FChannelOffsetIn.IsChanged)
            {
                AudioService.Engine.RemoveOutput(LastSignals);
                LastSignals.SliceCount = SpreadMax;
                for (int i = 0; i < SpreadMax; i++)
                {
                    LastSignals[i] = new MasterChannel(FInput[i], i + FChannelOffsetIn[i]);
                }

                AudioService.Engine.AddOutput(LastSignals);
            }
        }
Beispiel #2
0
    // ANCHOR_END: association_handler

    public static void Main(string[] args)
    {
        // ANCHOR: logging_init
        // Initialize logging with the default configuration
        // This may only be called once during program initialization
        Logging.Configure(
            new LoggingConfig(),
            new ConsoleLogger()
            );
        // ANCHOR_END: logging_init

        // ANCHOR: runtime_init
        var runtime = new Runtime(new RuntimeConfig {
            NumCoreThreads = 4
        });
        // ANCHOR_END: runtime_init

        // ANCHOR: create_master_channel
        var channel = MasterChannel.CreateTcpChannel(
            runtime,
            LinkErrorMode.Close,
            GetMasterChannelConfig(),
            new EndpointList("127.0.0.1:20000"),
            new ConnectStrategy(),
            new TestListener()
            );

        // ANCHOR_END: create_master_channel

        try
        {
            RunChannel(channel).GetAwaiter().GetResult();
        }
        finally
        {
            // ANCHOR: runtime_shutdown
            runtime.Shutdown();
            // ANCHOR_END: runtime_shutdown
        }
    }
Beispiel #3
0
    // ANCHOR_END: association_config

    private static async Task RunChannel(MasterChannel channel)
    {
        // ANCHOR: association_create
        var association = channel.AddAssociation(
            1024,
            GetAssociationConfig(),
            new TestReadHandler(),
            new TestAssocationHandler()
            );
        // ANCHOR_END: association_create

        // ANCHOR: add_poll
        var poll = channel.AddPoll(association, Request.ClassRequest(false, true, true, true), TimeSpan.FromSeconds(5));

        // ANCHOR_END: add_poll

        // start communications
        channel.Enable();

        while (true)
        {
            switch (await GetInputAsync())
            {
            case "x":
                return;

            case "enable":
            {
                channel.Enable();
                break;
            }

            case "disable":
            {
                channel.Disable();
                break;
            }

            case "dln":
            {
                channel.SetDecodeLevel(new DecodeLevel());
                break;
            }

            case "dlv":
            {
                channel.SetDecodeLevel(new DecodeLevel()
                    {
                        Application = AppDecodeLevel.ObjectValues
                    });
                break;
            }

            case "rao":
            {
                var request = new Request();
                request.AddAllObjectsHeader(Variation.Group40Var0);
                var result = await channel.Read(association, request);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "rmo":
            {
                var request = new Request();
                request.AddAllObjectsHeader(Variation.Group10Var0);
                request.AddAllObjectsHeader(Variation.Group40Var0);
                var result = await channel.Read(association, request);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "cmd":
            {
                // ANCHOR: assoc_control
                var commands = new Commands();
                commands.AddG12v1u8(3, new G12v1(new ControlCode(TripCloseCode.Nul, false, OpType.LatchOn), 1, 1000, 1000));
                var result = await channel.Operate(association, CommandMode.SelectBeforeOperate, commands);

                Console.WriteLine($"Result: {result}");
                // ANCHOR_END: assoc_control
                break;
            }

            case "evt":
            {
                channel.DemandPoll(poll);
                break;
            }

            case "lts":
            {
                var result = await channel.SynchronizeTime(association, TimeSyncMode.Lan);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "nts":
            {
                var result = await channel.SynchronizeTime(association, TimeSyncMode.NonLan);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "crt":
            {
                var result = await channel.ColdRestart(association);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "wrt":
            {
                var result = await channel.WarmRestart(association);

                Console.WriteLine($"Result: {result}");
                break;
            }

            case "lsr":
            {
                var result = await channel.CheckLinkStatus(association);

                Console.WriteLine($"Result: {result}");
                break;
            }

            default:
                Console.WriteLine("Unknown command");
                break;
            }
        }
    }