Esempio n. 1
0
        private void StartLog()
        {
            MQTTChannel <MQTTLogFile> logFileChannel = new MQTTChannel <MQTTLogFile>("Gimbl/Session/LogFile");

            logFileChannel.Event.AddListener(OnLogFileName);
            if (EditorPrefs.GetBool("Gimbl_externalLog", false) == false)
            {
                // Check if log file already exists.
                string filePath = Path.Combine(Application.dataPath, "Logs",
                                               string.Format("{0}-{1}.json", settings.outputFile, settings.sessionId));
                if (CheckFileExists(filePath))
                {
                    return;
                }
                // Create log file.
                logFile = new LogFile(filePath);
                //Update counter.
                settings.sessionId++;
                UnityEditor.EditorUtility.SetDirty(settings);
            }
            else
            {
                while (logFile == null)
                {
                }
                ;
                if (CheckFileExists(logFile.filePath))
                {
                    return;
                }
                ;
            }
        }
Esempio n. 2
0
 void Start()
 {
     // Create smooth buffer
     smoothBuffer = new ValueBuffer(GetBufferSize(settings.inputSmooth), true);
     if (this.GetType() == typeof(LinearTreadmill))
     {
         // Setup Listener.
         if (!settings.deviceIsSpherical)
         {
             MQTTChannel <MSG> channel = new MQTTChannel <MSG>(string.Format("{0}/Data", settings.deviceName));
             channel.Event.AddListener(OnMessage);
         }
         else
         {
             MQTTChannel <SphericalTreadmill.MSG> channel = new MQTTChannel <SphericalTreadmill.MSG>(string.Format("{0}/Data", settings.deviceName));
             channel.Event.AddListener(OnMessageSpherical);
         }
         // Start treadmill.
         statusChannel = new MQTTChannel <StatusMsg>(string.Format("{0}/Status", settings.deviceName), false);
         statusChannel.Send(new StatusMsg()
         {
             status = true
         });
     }
     // Setup tracking of settings changes.
     logSettings = new KeyLinearSettings();
     LogLinearSettings();
 }
Esempio n. 3
0
        public GimblObjectChan(string name, System.Action <T> reqFunc)
        {
            string          chanString = string.Format("Gimbl/{0}/{1}", name, reqFunc.Method.Name);
            MQTTChannel <T> chan       = new MQTTChannel <T>(chanString);

            action = reqFunc;
            chan.Event.AddListener(Callback);
        }
Esempio n. 4
0
 public void Start()
 {
     logger         = FindObjectOfType <LoggerObject>().logFile;
     actLogMsg.name = name;
     // Setup idle monitor.
     idleChan = new MQTTChannel <IdleMessage>("Gimbl/Idle/");
     idleStopWatch.Start();
     prevPos = transform.position;
 }
Esempio n. 5
0
 // Set MQTT Button Triggered channels.
 public void SetupChannels(string[] topics)
 {
     buttonChannels = new MQTTChannel[topics.Length];
     for (int i = 0; i < buttonChannels.Length; i++)
     {
         if (topics[i] != "")
         {
             buttonChannels[i] = new MQTTChannel(topics[i], false);
         }
     }
 }
Esempio n. 6
0
 public void Subscribe(MQTTChannel obj, string topic, byte qoslevel)
 {
     if (IsConnected())
     {
         client.Subscribe(new string[] { topic }, new byte[] { qoslevel });
         // Add topic and event pair to list.
         lock (channelList)
         {
             channelList.Add(new Channel()
             {
                 topic = topic, channel = obj
             });
         }
     }
 }
Esempio n. 7
0
        void Start()
        {
            // Get instance of logger.
            logger = FindObjectOfType <LoggerObject>();
            // Setup Listener.
            MQTTChannel <MSG> channel = new MQTTChannel <MSG>(string.Format("{0}/Data", settings.deviceName));

            channel.Event.AddListener(OnMessage);
            // Start treadmill.
            statusChannel = new MQTTChannel <StatusMsg>(string.Format("{0}/Status", settings.deviceName), false);
            statusChannel.Send(new StatusMsg()
            {
                status = true
            });
            // Create smooth buffer
            smoothBuffer = new ValueBuffer(GetBufferSize(settings.inputSmooth), true);
            // Setup tracking of settings changes.
            logSettings = new KeySphericalSettings();
            LogSphericalSettings();
        }
Esempio n. 8
0
        // Start is called before the first frame update
        void Start()
        {
            //Collision events.
            ColChan    = new MQTTChannel <ColliderMessage>(string.Format("Gimbl/{0}/Collision", name), false);
            PosChan    = new MQTTChannel <PositionMessage>(string.Format("Gimbl/{0}/Position", name), false);
            GetPosChan = new GimblObjectChan <FloatArray>(name, GetPosition);

            MoveChan      = new GimblObjectChan <FloatArray>(name, Move);
            MoveToChan    = new GimblObjectChan <FloatArray>(name, MoveTo);
            RotateChan    = new GimblObjectChan <FloatMsg>(name, Rotate);
            RotateToChan  = new GimblObjectChan <FloatMsg>(name, RotateTo);
            SetColorChan  = new GimblObjectChan <FloatArray>(name, SetColor);
            SetMatChan    = new GimblObjectChan <StringMessage>(name, SetMaterial);
            SetTexChan    = new GimblObjectChan <StringMessage>(name, SetTexture);
            SetOpacChan   = new GimblObjectChan <FloatMsg>(name, SetOpacity);
            SetVisChan    = new GimblObjectChan <BoolMsg>(name, SetVisibility);
            PlaySoundChan = new GimblObjectChan <BoolMsg>(name, PlaySound);
            SetBrightChan = new GimblObjectChan <FloatMsg>(name, SetBrightness);
            BlinkChan     = new GimblObjectChan <BlinkMsg>(name, Blink);
        }
Esempio n. 9
0
 void Start()
 {
     // Grab Settingss.
     ip        = UnityEditor.EditorPrefs.GetString("JaneliaVR_MQTT_IP");
     port      = UnityEditor.EditorPrefs.GetInt("JaneliaVR_MQTT_Port");
     sendFrame = UnityEditor.EditorPrefs.GetBool("Gimbl_sendFrameMsg");
     // Subscribe to some standard output channels.
     frameChannel     = new MQTTChannel("Gimbl/Frame", false);
     startChannel     = new MQTTChannel("Gimbl/Session/Start", false);
     stopChannel      = new MQTTChannel("Gimbl/Session/Stop", false);
     forceStopChannel = new MQTTChannel("Gimbl/Session/ForceStop", true);
     forceStopChannel.Event.AddListener(ForceStop);
     forceStartChannel = new MQTTChannel("Gimbl/Session/ForceStart", true);
     forceStartChannel.Event.AddListener(ForceStart);
     // wait for start signal.
     if (UnityEditor.EditorPrefs.GetBool("Gimbl_externalStart"))
     {
         while (requestStart == false && requestStop == false)
         {
         }
     }
     StartSession();
 }