예제 #1
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);
            }
        }
예제 #2
0
        public RJDevice(IDashboard view)
        {
            _view    = view;
            database = new Database();

            if (CheckReaPiLibrary() == true)
            {
                //rjConnection = new RJConnect((ReaPi.ConnectionIdentifier) 1, null);
                rjConnection = new RJConnect();

                //test API
                rjConnection.IOConfiguration = "osb_hr_1.dio";

                RegisterConnection();
                SetDigitalOutputsProperty();
            }
            else
            {
                _view.ShowProblemSolution(ErrorType.libraryError);
            }
        }