示例#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());
            }
        }
示例#2
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);
            }
        }
示例#3
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(), "");
            }
        }