Beispiel #1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to DeviceId return false.
            DeviceId p = obj as DeviceId;

            if ((System.Object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(p.ID1 == this.ID1 && p.ID2 == this.ID2 && p.ID3 == this.ID3);
        }
Beispiel #2
0
        /// <summary>
        /// Processes the device not responding (V1 receiver only).
        /// </summary>
        /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
        private void Process_HoguNotResponding(OpCodes opCode)
        {
            DeviceId id = new DeviceId();
            switch (opCode)
            {
                case OpCodes.ChungNotResponding:
                    id = _ChungDeviceId;
                    break;

                case OpCodes.HongNotResponding:
                    id = _HongDeviceId;
                    break;
            }

            Trace.TraceInformation("{0}. Process_HoguNotResponding: {1} Id={2}", CLASSNAME, opCode, id);

            if (id.IsValid())
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    OnDeviceStatusUpdate(new DeviceStatusEventData() { Receiver = this, DeviceId = id, DeviceStatus = DeviceStatusEnum.NotResponding });
                });
            }
        }
Beispiel #3
0
        /// <summary>
        /// Publishes the device registration.
        /// </summary>
        /// <param name="registrationData">The registration data.</param>
        private void Publish_DeviceRegistration(DeviceRegistrationEventData registrationData)
        {
            Trace.TraceInformation("{0}.Process_DeviceRegistration: OpCode={1} Match={2} Court={3} RegSeq={4} MinPressure={5} Touch={6} Id={7}",
                CLASSNAME, registrationData.OpCode, registrationData.GameNumber, registrationData.CourtNumber,
                registrationData.RegistrationSequence, registrationData.MinimumPressure, registrationData.TouchSensorMode,
                registrationData.Id);

            // Record registration sequence information for later verification
            lock (_deviceRegistrations)
            {
                if (_deviceRegistrations.ContainsKey(registrationData.Id))
                    _deviceRegistrations[registrationData.Id] = registrationData;
                else
                    _deviceRegistrations.Add(registrationData.Id, registrationData);
            }

            // Publish device registration event
            ThreadPool.QueueUserWorkItem(delegate
            {
                OnDeviceRegistered(registrationData);
            });

            #if EIDSS2
            // Keep track of Chung and Hong device Id as V1 (EIDSS 2.0) receiver does not provide them 
            // on data events unlike EIDSS 3.0 which does.
            switch (registrationData.OpCode)
            {
                case OpCodes.ChungRegistered:
                case OpCodes.ChungPreRegistered:
                    if (_HongDeviceId.Equals(registrationData.Id)) _HongDeviceId = new DeviceId();
                    _ChungDeviceId = registrationData.Id;
                    break;

                case OpCodes.HongRegistered:
                case OpCodes.HongPreRegistered:
                    if (_ChungDeviceId.Equals(registrationData.Id)) _ChungDeviceId = new DeviceId();
                    _HongDeviceId = registrationData.Id;
                    break;
            }
            #endif
        }