Ejemplo n.º 1
0
 protected virtual void OnPortStateChanged(PortEventArgs e)
 {
     if (PortStateChanged != null)
     {
         PortStateChanged(this, e);
     }
 }
        protected virtual void OnRaisePortReceived(PortEventArgs e)
        {
            var handler = PortReceived;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
        void serial_PortDateReceiveEvent(object sender, PortEventArgs e)
        {
            byte[] datas = e.buffer;
            string str   = System.Text.Encoding.Default.GetString(datas, 0, e.bytes);

            if (str.Contains("00FF") && (str.Length > 5) && (str.Length < 10))
            {
                M000 = (str.Substring(5, 1) == "1"?true:false);
                M001 = (str.Substring(6, 1) == "1" ? true : false);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Interrupt from the MAG3110 conversion complete interrupt.
 /// </summary>
 private void DigitalInputPortChanged(object sender, PortEventArgs e)
 {
     if (OnReadingComplete != null)
     {
         Read();
         var readings = new SensorReading();
         readings.X = X;
         readings.Y = Y;
         readings.Z = Z;
         OnReadingComplete(readings);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     Sensor has generated an interrupt, work out what to do.
        /// </summary>
        private void InterruptChanged(object sender, PortEventArgs e)
        {
            var status = Status;

            if ((status & StatusBitsMask.ActivityDetected) != 0)
            {
                Vector lastNotifiedReading = new Vector(_lastX, _lastY, _lastZ);
                Vector currentReading      = new Vector(X, Y, Z);
                _lastX = X;
                _lastY = Y;
                _lastZ = Z;
                AccelerationChanged(this, new SensorVectorEventArgs(lastNotifiedReading, currentReading));
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///     Alarm interrupt has been raised, work out which one and raise the necessary event.
 /// </summary>
 private void InterruptPort_Changed(object sender, PortEventArgs e)
 {
     if ((OnAlarm1Raised != null) || (OnAlarm2Raised != null))
     {
         var alarm = WhichAlarm;
         if (((alarm == Alarm.Alarm1Raised) || (alarm == Alarm.BothAlarmsRaised)) && (OnAlarm1Raised != null))
         {
             OnAlarm1Raised(this);
         }
         if (((alarm == Alarm.Alarm2Raised) || (alarm == Alarm.BothAlarmsRaised)) && (OnAlarm2Raised != null))
         {
             OnAlarm2Raised(this);
         }
     }
 }
Ejemplo n.º 7
0
        //-------------------------------------------------------------------------------------------------------------------
        // Подписки
        // Станция
        protected void PortAddedToApe(object sender, PortEventArgs e)
        {
            IPhoneExchange phoneExchange = sender as IPhoneExchange;

            if (phoneExchange != null && e != null && e.Port == this)
            {
                //Debug.WriteLine("[Port.PortAddedToApe] PortId: {0}", e.Port.PortId);

                phoneExchange.PortAdded    -= PortAddedToApe;
                phoneExchange.PortRemoved  += PortRemovedFromApe;
                phoneExchange.CallStarted  += IncommingCallReceived;
                phoneExchange.CallEnded    += IncommingCallEnded;
                phoneExchange.CallAccepted += OutgoingCallAccepted;
            }
        }
Ejemplo n.º 8
0
        //-------------------------------------------------------------------------------------------------------------------
        // Подписки
        // Порт
        public virtual void PortStateChanged(object sender, PortEventArgs e)
        {
            IPort port = sender as IPort;

            if (port != null && e != null && e.Port != null)
            {
                if (_port != null && _port != e.Port)
                {
                    return;
                }

                //Debug.WriteLine("[Terminal.PortStateChanged] Port: {0}, State: {1}", e.Port.PortId.Value, e.Port.PortState);

                if (e.Port.PortState == PortStates.NotConnected)
                {
                    // Есть незавершенный звонок
                    if (_call != null && _port != null)
                    {
                        CallEventArgs eventArgs = (CallEventArgs)_call.Clone();
                        if (eventArgs.State == CallEventStates.Accepted)
                        {
                            eventArgs.State = _call.SourcePortId == _port.PortId ? CallEventStates.OutgoingCallFinished : CallEventStates.IncommingCallFinished;
                        }
                        else
                        {
                            eventArgs.State = CallEventStates.Missed;
                        }
                        eventArgs.Date = _dtHelper.Now;
                        _call          = null;
                        OnCallEnded(eventArgs);
                    }

                    Unsubscribe();
                    _port = null;
                    _call = null;
                }
                else if (e.Port.PortState == PortStates.Connected && _port == null)
                {
                    _port = e.Port;
                    _port.CallReceived += IncommingCallReceived;
                    _port.CallEnded    += IncommingCallEnded;
                    _port.CallAccepted += OutgoingCallAccepted;
                }
            }
        }
Ejemplo n.º 9
0
 void context_OnNewPortConstructed(object sender, PortEventArgs e)
 {
 }
Ejemplo n.º 10
0
 private void Ports_WrittenPort(object sender, PortEventArgs e) => this.MaybeWrittenPort(e.Port);
Ejemplo n.º 11
0
 private void Ports_ReadingPort(object sender, PortEventArgs e) => this.MaybeReadingPort(e.Port);
Ejemplo n.º 12
0
 /// <summary>
 ///     Process the interrupt generated by the TSL2561.
 /// </summary>
 private void InterruptPin_Changed(object sender, PortEventArgs e)
 {
     ReadingOutsideThresholdWindow?.Invoke(DateTime.Now);
 }