Beispiel #1
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());
            }
        }
Beispiel #2
0
        private void RegisterConnection()
        {
            _connectionCallback = new ReaPi.connectionCallbackPtr(OnConnectionCallback);
            ReaPi.EErrorCode tmpError = ReaPi.RegisterConnectionCallback(_connectionCallback, new IntPtr(0));

            if (tmpError == ReaPi.EErrorCode.OK)
            {
                SendToDashboard(MessageType.LOG, "RegisterConnectionCallback() - Status.OK", "", "");
            }
            else
            {
                SendToDashboard(MessageType.LOG, "RegisterConnectionCallback() - Status.Error", tmpError.ToString(), "");
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
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);
        }
Beispiel #5
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);
            }
        }