private void OnDisconnect(ReaPi.ConnectionIdentifier connectionId) { rjConnection.ConnectionID = ReaPi.ConnectionIdentifier.INVALID_CONNECTION; SendToDashboard(MessageType.LOG, $"Połączenie <{connectionId}> zamknięte.", null, null); UpdateDashboard(EventType.DISCONNECT); }
public RJConnect(ReaPi.ConnectionIdentifier connectionID, Version protocolVersion) { ConnectionID = connectionID; ProtocolVersion = protocolVersion; //Job = (RJJob)null; Job = new RJJob(); IOConfiguration = ""; LabelContentHandle = ReaPi.CreateLabelContent(); }
private void OnConnectionCallback( ReaPi.ConnectionIdentifier connectionId, ReaPi.EConnState state, ReaPi.EErrorCode errorCode, IntPtr context) { if (state == ReaPi.EConnState.CONNECT) { if (connectionId > 0) { if (errorCode != ReaPi.EErrorCode.OK) { SendToDashboard(MessageType.ERROR, "Błąd podczas połączenia ze sterownikiem!", errorCode.ToString(), "OnConnectionCallback"); return; } rjConnection = new RJConnect(connectionId, null); _responseCallback = new ReaPi.responseCallbackPtr(OnResponseCallback); ReaPi.RegisterResponseCallback(connectionId, _responseCallback, context); _eventCallback = new ReaPi.eventCallbackPtr(OnEventCallback); ReaPi.RegisterEventCallback(connectionId, _eventCallback, context); OnConnect(connectionId); } else { SendToDashboard(MessageType.ERROR, $"Nieprawidłowy IdConnection: <{connectionId}>.", null, "OnConnectionCallback"); _view.ShowProblemSolution(ErrorType.errorConnection); } } else if (state == ReaPi.EConnState.DISCONNECT) { if (errorCode != ReaPi.EErrorCode.OK) { SendToDashboard(MessageType.ERROR, "Błąd podczas rozłączenia ze sterownikiem!", errorCode.ToString(), "OnConnectionCallback"); } OnDisconnect(connectionId); } else if (state == ReaPi.EConnState.CONNECTIONERROR) { SendToDashboard(MessageType.ERROR, "Błąd podczas połączenia <" + connectionId + ">.", errorCode.ToString(), "OnConnectionCallback"); UpdateDashboard(EventType.DISCONNECT); _view.ShowProblemSolution(ErrorType.errorConnection); } }
private void OnConnect(ReaPi.ConnectionIdentifier connectionId) { string lastError = ""; rjConnection.ProtocolVersion = new Version(ReaPi.GetProtocolVersion(rjConnection.ConnectionID)); lastError = ReaPi.SubscribeJobSet(rjConnection.ConnectionID, 1).ToString(); lastError = ReaPi.SubscribeIOConfigurationSet(rjConnection.ConnectionID, 1).ToString(); lastError = ReaPi.GetIOOutputLevel(rjConnection.ConnectionID).ToString(); //SetOutputLevel(OutputTypeReaction.ControlDivert, OutputLevel.Low); //SetOutputLevel(OutputTypeReaction.ControlStacker, OutputLevel.Low); SendToDashboard(MessageType.LOG, "Połączenie: OK", $" Wskaźnik połączenia: {rjConnection.ConnectionID.ToString()}.", null); SendToDashboard(MessageType.ERROR, lastError, null, null); UpdateDashboard(EventType.CONNECT); }
private void OnJobSetEvent(ReaPi.ConnectionIdentifier connection, int job, string jobFileName) { SendToDashboard(MessageType.EVENT, $"Job: <{jobFileName}>", null, null); if (!string.IsNullOrEmpty(jobFileName)) { try { rjConnection.Job = new RJJob(job, jobFileName); if (rjConnection.Job.VariableContents.Count > 0) { ISet <string> groups = rjConnection.Job.GetGroups(); //subskrypcja dla każdej grupy foreach (var group in groups) { ReaPi.SubscribeInvalidContent(connection, job, group).ToString(); ReaPi.SubscribeBufferFull(connection, job, group).ToString(); } } } catch (Exception) { } string logError; logError = ReaPi.SubscribeJobStarted(connection, job).ToString(); logError += ReaPi.SubscribeJobStopped(connection, job).ToString(); logError += ReaPi.SubscribeIOConfigurationSet(connection, job).ToString(); logError += ReaPi.SubscribePrintTrigger(connection, job).ToString(); logError += ReaPi.SubscribePrintStart(connection, job).ToString(); logError += ReaPi.SubscribePrintRejected(connection, job).ToString(); logError += ReaPi.SubscribePrintEnd(connection, job).ToString(); logError += ReaPi.SubscribePrintAborted(connection, job).ToString(); logError += ReaPi.SubscribePrintSpeedError(connection, job).ToString(); logError += ReaPi.SubscribeMissingContent(connection, job).ToString(); SendToDashboard(MessageType.ERROR, logError, "", ""); } else { ShowProblemSolution(ErrorType.nullJob); } }
private void OnResponseCallback( ReaPi.ResponseHandle response, ReaPi.ConnectionIdentifier connection, ReaPi.ECommandId commandid, ReaPi.EErrorCode errorCode, IntPtr context) { int error = 0; ErrorStatus errorStatus = ReaPi.GetErrorStatus(response, out error); switch (commandid) { case ReaPi.ECommandId.CMD_SUBSCRIBEJOBSET: CmdSubscribeJobSetResponse(true); break; case ReaPi.ECommandId.CMD_UNSUBSCRIBEJOBSET: CmdSubscribeJobSetResponse(false); break; case ReaPi.ECommandId.CMD_GETIOCONFIGURATION: CmdGetIOConfigurationResponse(ReaPi.GetIOConfigurationFilename(response, out error)); break; case ReaPi.ECommandId.CMD_GETIOOUTPUTLEVEL: CmdGetOutputLevelResponse(response, new GetIOOutputLevelResponseEventArgs(connection, response, commandid, ReaPi.GetErrorStatus(response, out error))); break; case ReaPi.ECommandId.CMD_SETIOOUTPUTLEVEL: CmdSetOutputLevelResponse(); break; default: break; } ShowResponseError(response, connection, commandid.ToString(), errorCode); }
private void ShowResponseError( ReaPi.ResponseHandle response, ReaPi.ConnectionIdentifier connectionId, string command, ReaPi.EErrorCode error) { if (error == ReaPi.EErrorCode.OK) { if (showResponseWithStatusOK == true) { SendToDashboard(MessageType.EVENT, $"{command}", null, null); } } else { int err = 0; string lastError = command + ", Błąd: " + error; string errorMessage = ReaPi.GetErrorMessage(response, out err); string errorDomain = ReaPi.GetErrorDomain(response, out err).ToString(); string errorCode = ReaPi.GetErrorCode(response, out err).ToString(); SendToDashboard(MessageType.ERROR, lastError, errorCode + " / " + errorDomain, errorMessage); } }
private void OnEventCallback( ReaPi.ResponseHandle response, ReaPi.ConnectionIdentifier connection, ReaPi.EEventId eventId, IntPtr context) { int error = 0; SendToDashboard(MessageType.EVENT, $"{eventId.ToString()}", null, null); switch (eventId) { case ReaPi.EEventId.JOBSET: OnJobSetEvent(connection, ReaPi.GetJobId(response, out error), ReaPi.GetJobFilename(response, out error)); break; case ReaPi.EEventId.JOBSTARTED: OnJobStartedEvent(); break; case ReaPi.EEventId.JOBSTOPPED: OnJobStoppedEvent(); break; case ReaPi.EEventId.PRINTTRIGGER: OnJobPrintTriggerEvent(eventId); break; case ReaPi.EEventId.PRINTSTART: OnJobPrintStartEvent(eventId); break; case ReaPi.EEventId.PRINTREJECTED: OnJobPrintRejectEvent(); break; case ReaPi.EEventId.PRINTEND: OnJobPrintEndEvent(); break; case ReaPi.EEventId.PRINTABORTED: OnJobPrintAbortedEvent(); break; case ReaPi.EEventId.PRINTSPEEDERROR: OnJobPrintSpeedErrorEvent(); break; case ReaPi.EEventId.INVALIDCONTENT: OnInvalidContentEvent(ReaPi.GetGroupname(response, out error)); break; case ReaPi.EEventId.IOCONFIGURATIONSET: OnIOConfigurationSetEvent(ReaPi.GetIOConfigurationFilename(response, out error)); break; case ReaPi.EEventId.MISSINGCONTENT: OnMissingContentEvent(ReaPi.GetGroupname(response, out error)); break; case ReaPi.EEventId.BUFFERFULL: OnJobBufferFullEvent(ReaPi.GetJobErrorStatus(response, out error)); break; default: break; } }