diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 5e6fdbc63..b901bd224 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -787,6 +787,11 @@ namespace Tango.Emulations.Emulators lastProgress = progress; Thread.Sleep(100); + + if (_cancelJob) + { + break; + } } if (_cancelJob) @@ -795,7 +800,7 @@ namespace Tango.Emulations.Emulators } } - foreach( var packLevel in MachineStatus.IDSPacksLevels) + foreach (var packLevel in MachineStatus.IDSPacksLevels) { Debug.WriteLine($"packLevel.DispenserLevel = {packLevel.DispenserLevel}"); Debug.WriteLine($"quantity = {130000000 - packLevel.DispenserLevel}"); @@ -810,14 +815,14 @@ namespace Tango.Emulations.Emulators Transporter.SendResponse<JobResponse>(new JobResponse() { - }, request.Container.Token, false, ErrorCode.ContinuousResponseAborted); + }, request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.ContinuousResponseAborted }); } else { Transporter.SendResponse<ResumeCurrentJobResponse>(new ResumeCurrentJobResponse() { - }, _current_job_resume_token, false, ErrorCode.ContinuousResponseAborted); + }, _current_job_resume_token, new TransportResponseConfig() { ErrorCode = ErrorCode.ContinuousResponseAborted }); } } else @@ -831,7 +836,7 @@ namespace Tango.Emulations.Emulators Progress = unit_length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS, } - }, request.Container.Token, !_cancelJob); + }, request.Container.Token, new TransportResponseConfig() { Completed = !_cancelJob }); } else { @@ -842,7 +847,7 @@ namespace Tango.Emulations.Emulators Progress = unit_length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS, } - }, _current_job_resume_token, !_cancelJob); + }, _current_job_resume_token, new TransportResponseConfig() { Completed = !_cancelJob }); } } @@ -854,8 +859,8 @@ namespace Tango.Emulations.Emulators { //if (_jobAbortCounter == 1) //{ - _cancelJob = true; - Transporter.SendResponse<AbortJobResponse>(new AbortJobResponse(), request.Container.Token); + _cancelJob = true; + Transporter.SendResponse<AbortJobResponse>(new AbortJobResponse(), request.Container.Token); // _jobAbortCounter = 0; //} //else @@ -930,7 +935,7 @@ namespace Tango.Emulations.Emulators Thread.Sleep(30); } - Transporter.SendResponse<MotorHomingResponse>(new MotorHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, true); + Transporter.SendResponse<MotorHomingResponse>(new MotorHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, new TransportResponseConfig() { Completed = true }); _motorHomingRequestCodes.Remove(homeRequest.MotorType); ResetGraphFactors(); }); @@ -1001,7 +1006,7 @@ namespace Tango.Emulations.Emulators Thread.Sleep(30); } - Transporter.SendResponse<DispenserHomingResponse>(new DispenserHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, true); + Transporter.SendResponse<DispenserHomingResponse>(new DispenserHomingResponse() { MaxProgress = 100, Progress = 100 }, request.Container.Token, new TransportResponseConfig() { Completed = true }); _dispenserHomingRequestCodes.Remove(homeRequest.Index); ResetGraphFactors(); }); @@ -1024,7 +1029,7 @@ namespace Tango.Emulations.Emulators } else { - Transporter.SendResponse<SetDigitalOutResponse>(new SetDigitalOutResponse(), request.Container.Token, null, ErrorCode.InvalidDigitalPinNumber); + Transporter.SendResponse<SetDigitalOutResponse>(new SetDigitalOutResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.InvalidDigitalPinNumber }); } } @@ -1124,7 +1129,7 @@ namespace Tango.Emulations.Emulators DiagnosticsInterval = (uint)DIAGNOSTICS_INTERVAL, }, IsAfterReset = _isAfterReset, - }, request.Container.Token, null, request.Message.Password == "1234" ? ErrorCode.None : ErrorCode.UnauthorizedConnection); + }, request.Container.Token, new TransportResponseConfig() { ErrorCode = request.Message.Password == "1234" ? ErrorCode.None : ErrorCode.UnauthorizedConnection }); _connectionTime = DateTime.Now; @@ -1234,7 +1239,7 @@ namespace Tango.Emulations.Emulators } else { - Transporter.SendResponse<ResumeCurrentJobResponse>(new ResumeCurrentJobResponse(), request.Container.Token, true, ErrorCode.NoJobInProgress); + Transporter.SendResponse<ResumeCurrentJobResponse>(new ResumeCurrentJobResponse(), request.Container.Token, new TransportResponseConfig() { Completed = true, ErrorCode = ErrorCode.NoJobInProgress }); } } @@ -1300,7 +1305,7 @@ namespace Tango.Emulations.Emulators msg = ex.Message; } - Transporter.SendResponse<GetFilesResponse>(response, request.Container.Token, false, failed ? ErrorCode.GeneralError : ErrorCode.None, msg); + Transporter.SendResponse<GetFilesResponse>(response, request.Container.Token, new TransportResponseConfig() { ErrorCode = failed ? ErrorCode.GeneralError : ErrorCode.None, ErrorMessage = msg }); } private void HandleFileDownloadRequest(TangoMessage<FileDownloadRequest> request) @@ -1311,7 +1316,7 @@ namespace Tango.Emulations.Emulators { DownloadID = Guid.NewGuid().ToString(), MaxChunkLength = Math.Min(MAX_CHUNK_LENGTH, length), - }, request.Container.Token, null, File.Exists(request.Message.FileName) ? ErrorCode.None : ErrorCode.FileNotFound); + }, request.Container.Token, new TransportResponseConfig() { ErrorCode = File.Exists(request.Message.FileName) ? ErrorCode.None : ErrorCode.FileNotFound }); } private void HandleFileChunkDownloadRequest(TangoMessage<FileChunkDownloadRequest> request) @@ -1336,7 +1341,7 @@ namespace Tango.Emulations.Emulators Transporter.SendResponse<FileChunkDownloadResponse>(new FileChunkDownloadResponse() { - }, request.Container.Token, null, ErrorCode.FileRequestDenied, ex.Message); + }, request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.FileRequestDenied, ErrorMessage = ex.Message }); } } @@ -1349,7 +1354,7 @@ namespace Tango.Emulations.Emulators } catch (Exception ex) { - Transporter.SendResponse<CreateResponse>(new CreateResponse(), request.Container.Token, null, ErrorCode.FileRequestInvalidParameter, ex.Message); + Transporter.SendResponse<CreateResponse>(new CreateResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.FileRequestInvalidParameter, ErrorMessage = ex.Message }); } } @@ -1370,7 +1375,7 @@ namespace Tango.Emulations.Emulators } catch (Exception ex) { - Transporter.SendResponse<DeleteResponse>(new DeleteResponse(), request.Container.Token, null, ErrorCode.FileRequestInvalidParameter, ex.Message); + Transporter.SendResponse<DeleteResponse>(new DeleteResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.FileRequestInvalidParameter, ErrorMessage = ex.Message }); } } @@ -1403,7 +1408,7 @@ namespace Tango.Emulations.Emulators } catch (Exception ex) { - Transporter.SendResponse<FileChunkUploadResponse>(new FileChunkUploadResponse(), request.Container.Token, null, ErrorCode.GeneralError, ex.Message); + Transporter.SendResponse<FileChunkUploadResponse>(new FileChunkUploadResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.GeneralError, ErrorMessage = ex.Message }); } } @@ -1424,7 +1429,7 @@ namespace Tango.Emulations.Emulators } catch (Exception ex) { - Transporter.SendResponse<ValidateVersionResponse>(new ValidateVersionResponse(), request.Container.Token, null, ErrorCode.GeneralError, ex.Message); + Transporter.SendResponse<ValidateVersionResponse>(new ValidateVersionResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.GeneralError, ErrorMessage = ex.Message }); } }); } @@ -1446,7 +1451,7 @@ namespace Tango.Emulations.Emulators } catch (Exception ex) { - Transporter.SendResponse<ActivateVersionResponse>(new ActivateVersionResponse(), request.Container.Token, null, ErrorCode.GeneralError, ex.Message); + Transporter.SendResponse<ActivateVersionResponse>(new ActivateVersionResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.GeneralError, ErrorMessage = ex.Message }); } }); } @@ -1478,7 +1483,7 @@ namespace Tango.Emulations.Emulators ProgressPercentage = 100, Message = "Machine is turned off", State = PowerDownState.PowerOffCompleted - }, request.Container.Token, true); + }, request.Container.Token, new TransportResponseConfig() { Completed = true }); }); } @@ -1517,7 +1522,7 @@ namespace Tango.Emulations.Emulators } else { - await Transporter.SendResponse<ContinueThreadLoadingResponse>(new ContinueThreadLoadingResponse(), request.Container.Token, null, ErrorCode.GeneralError, "StartThreadLoadingRequest was never sent."); + await Transporter.SendResponse<ContinueThreadLoadingResponse>(new ContinueThreadLoadingResponse(), request.Container.Token, new TransportResponseConfig() { ErrorCode = ErrorCode.GeneralError, ErrorMessage = "StartThreadLoadingRequest was never sent." }); } } @@ -1531,7 +1536,7 @@ namespace Tango.Emulations.Emulators { Action = CartridgeAction.Inserted, - }, TimeSpan.FromSeconds(10)); + }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(10) }); return response.Message.Index; } |
