public static void SetProcessState(LogShowDevice dev, ServerRunState state) { foreach (var process in processList) { process.State = state; } }
//TODO: Call this to launch the feedback when the server launches (if needed) public void StartFeedbackCore(string trackerName, int sensorNumber) { serverName = trackerName; watchedSensor = sensorNumber; forceStop = false; clientState = ServerRunState.Starting; RunFeedbackCoreDelegate feedbackDelegate = RunFeedbackCore; feedbackDelegate.BeginInvoke(null, null); }
public void launchServer() { //These don't need a lock to be thread safe since they are volatile forceStop = false; serverState = ServerRunState.Starting; string errorMessage = ""; if (serverMasterOptions.parseSettings(out errorMessage)) { //Start the Kinect audio streams and create the per Kinect skeleton lists for (int i = 0; i < kinects.Count; i++) { kinects[i].StartKinectAudio(); //TODO: This will crash if the Kinects are in another thread (i.e. console mode) } //Start the feedback client if necessary if (serverMasterOptions.feedbackOptions.useFeedback) { feedbackCore = new FeedbackCore(verbose, this, parent); feedbackCore.StartFeedbackCore(serverMasterOptions.feedbackOptions.feedbackServerName, serverMasterOptions.feedbackOptions.feedbackSensorNumber); } runServerCoreDelegate serverDelegate = runServerCore; serverDelegate.BeginInvoke(null, null); //Start voice recognition, if necessary if (serverMasterOptions.voiceCommands.Count > 0) { voiceRecog = new VoiceRecogCore(this, verbose, parent); launchVoiceRecognizerDelegate voiceDelegate = voiceRecog.launchVoiceRecognizer; //Dispatcher newDispatch = new Dispatcher(); voiceDelegate.BeginInvoke(new AsyncCallback(voiceStartedCallback), null); //voiceRecog.launchVoiceRecognizer(); } else { //Because the voice callback will not be called, we need to call this stuff here if (GUI) { parent.startServerButton.Content = "Stop"; parent.startServerButton.IsEnabled = true; parent.ServerStatusItem.Content = "Running"; parent.ServerStatusTextBlock.Text = "Running"; } } } else { HelperMethods.ShowErrorMessage("Error", "Settings parsing failed! See the log for more details.", parent); HelperMethods.WriteToLog(errorMessage, parent); } }
public async Task <bool> SendPowerSignalAsync(string id, ServerRunState state, CancellationToken token = default) { var payload = new { Signal = state.ToString().ToLower() }; var request = new RestRequest($"/api/client/servers/{id}/power", Method.POST) .AddJsonBody(payload); var response = await HandleRequestRawAsync(request, token); return(response.IsSuccessful); }
private void RunFeedbackCore() { Connection clientConnection = Connection.GetConnectionByName(serverName); TrackerRemote client = new TrackerRemote(serverName, clientConnection); client.PositionChanged += client_PositionChanged; clientState = ServerRunState.Running; while (!forceStop) { clientConnection.Update(); client.Update(); Thread.Yield(); } clientState = ServerRunState.Stopping; client.PositionChanged -= client_PositionChanged; client.Dispose(); clientConnection.Dispose(); clientState = ServerRunState.Stopped; }
private void runServerCore() { //Create the connection for all the servers vrpnConnection = Connection.CreateServerConnection(); //Set up all the analog servers analogServers = new List <AnalogServer>(); for (int i = 0; i < serverMasterOptions.analogServers.Count; i++) { lock (serverMasterOptions.analogServers[i]) { //Note: This uses maxChannelUsed NOT trueChannelCount in case non-consecutive channels are used analogServers.Add(new AnalogServer(serverMasterOptions.analogServers[i].serverName, vrpnConnection, serverMasterOptions.analogServers[i].maxChannelUsed + 1)); analogServers[i].MuteWarnings = !verbose; } } //Set up all the button servers buttonServers = new List <ButtonServer>(); for (int i = 0; i < serverMasterOptions.buttonServers.Count; i++) { lock (serverMasterOptions.buttonServers[i]) { //Note: This uses maxButtonUsed NOT trueButtonCount in case non-consecutive buttons are used buttonServers.Add(new ButtonServer(serverMasterOptions.buttonServers[i].serverName, vrpnConnection, serverMasterOptions.buttonServers[i].maxButtonUsed + 1)); buttonServers[i].MuteWarnings = !verbose; } } //Set up all the text servers textServers = new List <TextSender>(); for (int i = 0; i < serverMasterOptions.textServers.Count; i++) { lock (serverMasterOptions.textServers[i]) { textServers.Add(new TextSender(serverMasterOptions.textServers[i].serverName, vrpnConnection)); textServers[i].MuteWarnings = !verbose; } } //Set up all the tracker servers trackerServers = new List <TrackerServer>(); for (int i = 0; i < serverMasterOptions.trackerServers.Count; i++) { lock (serverMasterOptions.trackerServers[i]) { trackerServers.Add(new TrackerServer(serverMasterOptions.trackerServers[i].serverName, vrpnConnection, serverMasterOptions.trackerServers[i].sensorCount)); trackerServers[i].MuteWarnings = !verbose; } } //The server isn't really running until everything is setup here. serverState = ServerRunState.Running; //Run the server while (!forceStop) { //Update the analog servers updateList(ref analogServers); updateList(ref buttonServers); updateList(ref textServers); updateList(ref trackerServers); lock (vrpnConnection) { vrpnConnection.Update(); } Thread.Yield(); // Be polite, but don't add unnecessary latency. } //Cleanup everything //Dispose the analog servers serverState = ServerRunState.Stopping; disposeList(ref analogServers); disposeList(ref buttonServers); disposeList(ref textServers); disposeList(ref trackerServers); lock (vrpnConnection) { vrpnConnection.Dispose(); } serverState = ServerRunState.Stopped; }
public async Task <bool> SendPowerSignalAsync(Server server, ServerRunState state, CancellationToken token = default) { return(await SendPowerSignalAsync(server.Identifier, state, token)); }