예제 #1
0
        /// <summary>
        /// Called when a device is sucessfully registered to the receiver. We need to add
        /// or update it with the scoreekeeper competitors service.
        /// </summary>
        /// <param name="deviceRegistration">The device registration.</param>
        protected void OnDeviceRegistration(DeviceRegistrationEventArgs deviceRegistration)
        {
            var competitor = this.ScoreKeeperService.Competitors.FirstOrDefault(c => c.DeviceId.Equals(deviceRegistration.Id));

            if (competitor != null)
            {
                competitor.DeviceType = deviceRegistration.OperationCode;
            }
            else
            {
                this.ScoreKeeperService.Competitors.Add(new CompetitorModel(deviceRegistration));
            }

            // Attempt to match up partners
            this.MatchPartners();
        }
예제 #2
0
 /// <summary>
 /// Raises the <see cref="E:DeviceRegistered"/> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The Device Registration Event Data.</param>
 protected virtual void OnDeviceRegistered(object sender, DeviceRegistrationEventArgs e)
 {
     EventHandler<DeviceRegistrationEventArgs> handler = this.DeviceRegistered;
     try
     {
         handler(this, e);
     }
     catch (Exception ex)
     {
         Trace.TraceError("{0}.OnDeviceRegistered: {1}", CLASSNAME, ex.GetBaseException());
         throw;
     }
 }
예제 #3
0
 /// <summary>
 /// Processes the device registration.
 /// </summary>
 /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
 /// <returns>Device Registration Event Data</returns>
 private DeviceRegistrationEventArgs Process_DeviceRegistration(DataPacketReceivedEventArgs e)
 {
     // Parse data packet into registration data structure
     DeviceRegistrationEventArgs registrationData = new DeviceRegistrationEventArgs()
     {
         ReceiverId = this.Id,
         GameNumber = e.DataPacket[(byte)RegistrationDataFields.GameNumber],
         OperationCode = (OpCodes)e.DataPacket[(byte)RegistrationDataFields.OpCode],
         CourtNumber = e.DataPacket[(byte)RegistrationDataFields.CourtNumber],
         RegistrationSequence = e.DataPacket[(byte)RegistrationDataFields.RegSequence],
         MinimumPressure = e.DataPacket[(byte)RegistrationDataFields.MinimumImpact],
         TouchSensorMode = (TouchSensorStatusEnum)e.DataPacket[(byte)RegistrationDataFields.TouchSensorMode],
         Id = new DeviceId(e.DataPacket[(byte)RegistrationDataFields.Id1], e.DataPacket[(byte)RegistrationDataFields.Id2], e.DataPacket[(byte)RegistrationDataFields.Id3])
     };
     return registrationData;
 }
예제 #4
0
        /// <summary>
        /// Publishes the device registration.
        /// </summary>
        /// <param name="registrationData">The registration data.</param>
        private void Publish_DeviceRegistration(DeviceRegistrationEventArgs registrationData)
        {
            Trace.TraceInformation(
                "{0}.Process_DeviceRegistration: OpCode={1} Match={2} Court={3} RegSeq={4} MinPressure={5} Touch={6} Id={7}",
                CLASSNAME,
                registrationData.OperationCode,
                registrationData.GameNumber,
                registrationData.CourtNumber,
                registrationData.RegistrationSequence,
                registrationData.MinimumPressure,
                registrationData.TouchSensorMode,
                registrationData.Id);

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

            // Publish device registration event
            ThreadPool.QueueUserWorkItem(delegate
            {
                this.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.OperationCode)
            {
                case OpCodes.ChungRegistered:
                case OpCodes.ChungPreRegistered:
                    if (this.hongDeviceId.Equals(registrationData.Id))
                    {
                        this.hongDeviceId = new DeviceId();
                    }

                    this.chungDeviceId = registrationData.Id;
                    break;

                case OpCodes.HongRegistered:
                case OpCodes.HongPreRegistered:
                    if (this.chungDeviceId.Equals(registrationData.Id))
                    {
                        this.chungDeviceId = new DeviceId();
                    }

                    this.hongDeviceId = registrationData.Id;
                    break;
            }
#endif
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompetitorModel"/> class,
 /// takes a registration instance and populates the device Id, Device Type, 
 /// default name and required impact level fields from the data.
 /// </summary>
 /// <param name="registration">
 /// The registration.
 /// </param>
 public CompetitorModel(DeviceRegistrationEventArgs registration)
 {
     this.registration = registration;
     this.DeviceId = this.registration.Id;
     this.DeviceType = this.registration.OperationCode;
     this.RequiredImpactLevel = this.registration.MinimumPressure;
     this.DisplayName = GetDefaultDisplayName(this.registration.OperationCode);
 }