Exemplo n.º 1
0
        private void CmdGetOutputLevelResponse(ReaPi.ResponseHandle response, GetIOOutputLevelResponseEventArgs getIOOutputLevelResponseEventArgs)
        {
            int error = 0;
            List <GetIOOutputLevelResponseEventArgs.IOOutput> listIOOutputs = new List <GetIOOutputLevelResponseEventArgs.IOOutput>();
            int count = ReaPi.GetNumberOfOutputs(response, out error);

            for (int i = 1; i <= count; i++)
            {
                GetIOOutputLevelResponseEventArgs.IOOutput ioOutput = new GetIOOutputLevelResponseEventArgs.IOOutput();
                ioOutput.Index = i;
                ioOutput.Level = ReaPi.GetIOOutputLevelValue(response, i, out error);

                listIOOutputs.Add(ioOutput);
            }

            List <bool> outputsState = new List <bool>();

            for (int i = 0; i < getIOOutputLevelResponseEventArgs.IOOutputs.Count; i++)
            {
                outputsState.Add((bool)getIOOutputLevelResponseEventArgs.IOOutputs[i].Level);
            }
            try
            {
                _view.UpdateOutputsState(outputsState);
            }
            catch (Exception) { }
        }
Exemplo n.º 2
0
        private void SetLabelContent(List <DTOVariableContent> dtoVC)
        {
            try
            {
                if (rjConnection.ConnectionID <= 0)
                {
                    return;
                }

                ReaPi.EErrorCode         error = ReaPi.RemoveLabelContent(rjConnection.LabelContentHandle);
                ReaPi.LabelContentHandle labelContentHandle = ReaPi.CreateLabelContent();

                rjConnection.LabelContentHandle = labelContentHandle;

                if (labelContentHandle >= (ReaPi.LabelContentHandle) 0)
                {
                    foreach (var lp in dtoVC)
                    {
                        error = ReaPi.PrepareLabelContent(labelContentHandle, 1, lp.GroupName, lp.ObjectName, lp.ContentName, lp.ContentValue);

                        if (error != ReaPi.EErrorCode.OK)
                        {
                            SendToDashboard(MessageType.LOG, "Error: Nie można przygotować danych dla pola: {lp.ContentName}", error.ToString(), null);
                        }
                    }

                    ReaPi.ResponseHandle response = ReaPi.SetLabelContent(rjConnection.ConnectionID, labelContentHandle);

                    if (response < 0)
                    {
                        SendToDashboard(MessageType.LOG, "Error: Nie można wysłać danych dla etykiety", null, null);
                    }
                    else
                    {
                        SendToDashboard(MessageType.LOG, $"Wysłano zawartość rekordu: {database.ActualRecord.ToString()}", null, null);

                        Record record = new Record();
                        record.Id      = database.ActualRecord;
                        record.IsError = false;

                        _queueRecords.Enqueue(record);
                    }
                }
                else
                {
                    SendToDashboard(MessageType.LOG, "Error: Nie można przygotować danych dla etykiety", null, null);
                }
            }
            catch (FormatException ex)
            {
                SendToDashboard(MessageType.ERROR, "Function SetLabelContent()", ex.ToString(), ex.Message.ToString());
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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;
            }
        }