Exemple #1
0
    public async void RunTest()
    {
        Debug.Log("TestProcessingModulesFrequency started ...");

        Ubii.Services.ServiceReply reply = await ubiiNode.CallService(new Ubii.Services.ServiceRequest
        {
            Topic   = UbiiConstants.Instance.DEFAULT_TOPICS.SERVICES.SESSION_RUNTIME_START,
            Session = ubiiSession
        });

        //Debug.Log("TestProcessingModules.RunTest() - reply to start session: " + reply);
        if (reply.Session != null)
        {
            ubiiSession = reply.Session;
        }

        await Task.Delay(5000);

        reply = await ubiiNode.CallService(new Ubii.Services.ServiceRequest
        {
            Topic   = UbiiConstants.Instance.DEFAULT_TOPICS.SERVICES.SESSION_RUNTIME_STOP,
            Session = ubiiSession
        });

        //Debug.Log("TestProcessingModules.RunTest() - reply to stop session: " + reply);

        if (testFailure)
        {
            Debug.LogError("TestProcessingModulesFrequency FAILURE");
        }
        else
        {
            Debug.Log("TestProcessingModulesFrequency SUCCESS");
        }
    }
Exemple #2
0
    public async void OnUbiiInitialized()
    {
        topicFrequencyCounter          = "/" + ubiiNode.GetID() + "/test/pm_frequency_counter";
        topicFrequencyCounterTickValue = "/" + ubiiNode.GetID() + "/test/pm_frequency_counter/tick_value";

        expectedCounter = 0;
        tickValue       = 2;
        ubiiNode.PublishImmediately(new TopicDataRecord
        {
            Topic = topicFrequencyCounterTickValue,
            Int32 = tickValue
        });
        //await Task.Delay(2000);

        testFailure = false;
        await ubiiNode.SubscribeTopic(topicFrequencyCounter, (TopicDataRecord record) =>
        {
            expectedCounter += tickValue;
            testFailure      = record.Int32 != expectedCounter;
            if (testFailure)
            {
                Debug.LogError("counter from PM expected to be " + expectedCounter + " but was actually " + record.Int32);
            }
        });

        ubiiSession = new Ubii.Sessions.Session {
            Name = "Test Processing Modules Counter"
        };

        ubiiSession.ProcessingModules.Add(new Ubii.Processing.ProcessingModule
        {
            Name = TestPMFrequencyCounter.specs.Name
        });

        Ubii.Sessions.IOMapping ioMapping = new Ubii.Sessions.IOMapping();
        ioMapping.ProcessingModuleName = TestPMFrequencyCounter.specs.Name;
        ioMapping.InputMappings.Add(new Ubii.Sessions.TopicInputMapping
        {
            InputName = "counterTick",
            Topic     = topicFrequencyCounterTickValue
        });
        ioMapping.OutputMappings.Add(new Ubii.Sessions.TopicOutputMapping
        {
            OutputName = "outCounter",
            Topic      = topicFrequencyCounter
        });
        ubiiSession.IoMappings.Add(ioMapping);

        RunTest();
    }
Exemple #3
0
    private void CreateSpecs()
    {
        this.inputTopic  = "/" + ubiiNode.GetID() + "/test-sessions/input/vec3";
        this.outputTopic = "/" + ubiiNode.GetID() + "/test-sessions/output/vec3";

        this.pmSpecs = new Ubii.Processing.ProcessingModule
        {
            Name = "Unity3D-Client-TestSessions-PM-01",
            OnProcessingStringified = "(inputs, outputs, state) => { outputs.outVec3 = inputs.inVec3; }",
            ProcessingMode          = new Ubii.Processing.ProcessingMode {
                Frequency = new Ubii.Processing.ProcessingMode.Types.Frequency {
                    Hertz = 10
                }
            }
        };
        this.pmSpecs.Inputs.Add(new Ubii.Processing.ModuleIO {
            InternalName = "inVec3", MessageFormat = "ubii.dataStructure.Vector3"
        });
        this.pmSpecs.Outputs.Add(new Ubii.Processing.ModuleIO {
            InternalName = "outVec3", MessageFormat = "ubii.dataStructure.Vector3"
        });
        this.pmSpecs.Authors.Add("Sandro Weber");

        this.sessionSpecs = new Ubii.Sessions.Session
        {
            Name = "Unity3D-Client-TestSessions-Session-01"
        };
        this.sessionSpecs.Authors.Add("Sandro Weber");
        this.sessionSpecs.ProcessingModules.Add(this.pmSpecs);
        Ubii.Sessions.IOMapping ioMapping = new Ubii.Sessions.IOMapping
        {
            ProcessingModuleName = this.pmSpecs.Name
        };
        ioMapping.InputMappings.Add(new Ubii.Sessions.TopicInputMapping {
            InputName = "inVec3", Topic = this.inputTopic
        });
        ioMapping.OutputMappings.Add(new Ubii.Sessions.TopicOutputMapping {
            OutputName = "outVec3", Topic = this.outputTopic
        });
        this.sessionSpecs.IoMappings.Add(ioMapping);
    }
Exemple #4
0
    async private void RunTestStartStopSession()
    {
        bool success = false;

        Ubii.Services.ServiceReply replyStart = await ubiiNode.CallService(
            new Ubii.Services.ServiceRequest {
            Topic = ubiiConstants.DEFAULT_TOPICS.SERVICES.SESSION_RUNTIME_START, Session = this.sessionSpecs
        }
            );

        if (replyStart.Session != null)
        {
            this.sessionSpecs = replyStart.Session;

            await Task.Delay(1000);

            Ubii.Services.ServiceReply replyStop = await ubiiNode.CallService(
                new Ubii.Services.ServiceRequest {
                Topic = ubiiConstants.DEFAULT_TOPICS.SERVICES.SESSION_RUNTIME_STOP, Session = this.sessionSpecs
            }
                );

            if (replyStop.Success != null)
            {
                Debug.Log("RunTestStartStopSession SUCCESS!");
            }
            else
            {
                Debug.LogError("RunTestStartStopSession FAILURE! Could not stop session.");
            }
        }
        else
        {
            Debug.LogError("RunTestStartStopSession FAILURE! Could not start session.");
        }
    }