void ForceStop() { // Send stop stopChannel.Send(); System.Threading.Thread.Sleep(1000); requestStop = true; }
void OnTriggerEnter(Collider other) { Debug.Log(name); ColChan.Send(new ColliderMessage() { collider = other.name }); }
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(); }
void GetPosition(FloatArray msg) { PosChan.Send(new PositionMessage() { position = new float[] { transform.position.x, transform.position.y, transform.position.z } }); }
void OnApplicationQuit() { if (this.GetType() == typeof(LinearTreadmill)) { statusChannel.Send(new StatusMsg() { status = false }); } }
void LateUpdate() { if (sendFrame) { frameChannel.Send(); } if (requestStop) { UnityEditor.EditorApplication.isPlaying = false; } }
public void LateUpdate() { // Log Absolute Position. int roundFct = 1000; actLogMsg.position[0] = (int)(gameObject.transform.position.x * roundFct); actLogMsg.position[1] = (int)(gameObject.transform.position.y * roundFct); actLogMsg.position[2] = (int)(gameObject.transform.position.z * roundFct); actLogMsg.heading[0] = (int)(gameObject.transform.rotation.x * roundFct); actLogMsg.heading[1] = (int)(gameObject.transform.rotation.y * roundFct); actLogMsg.heading[2] = (int)(gameObject.transform.rotation.z * roundFct); logger.Log("Position", actLogMsg); // Log position on path (if applicable). if (controller != null) { if (controller.master.GetType() == typeof(LinearTreadmill) || controller.master.GetType() == typeof(SimulatedLinearTreadmill)) { if (((LinearTreadmill)controller.master).path != null) { pathMsg.name = name; pathMsg.pathName = ((LinearTreadmill)controller.master).path.name; pathMsg.position = (int)(((LinearTreadmill)controller.master).path.path.GetClosestDistanceAlongPath(gameObject.transform.position) * 1000); logger.Log("Path Position", pathMsg); } } } // Check idle. if (idleStopWatch.ElapsedMilliseconds > 2000) { idleStopWatch.Restart(); if (Vector3.Distance(prevPos, transform.position) < 0.5) { idleTime += 2000; if (idleTime > (settings.idleTimeOut * 1000 * 60)) { prevPos = transform.position; idleTime = 0; // Send signal. idleMsg.name = name; idleMsg.idleTime = (int)(settings.idleTimeOut * 60000); idleChan.Send(idleMsg); logger.Log("Idle!"); } } else { prevPos = transform.position; idleTime = 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(); }
async void StartSession() { await Task.Delay(1000); startChannel.Send(); }