Example #1
0
        public static void Main(string[] args)
        {
            _Lease = new Lease();
              _outputDatum = new InterfaceDatum();
              _datumLock = new ReaderWriterLockSlim();
              uint ticks = 0;
              uint pedalRotations = 0;
              _userName = args[1];
              _password = args[2];

              if (args[0] == @"Test")
              {
            _pollServer = new Timer(SendDataToServer, null, 0, POLL_INTERVAL);

            Random rnd = new Random();
            ushort pwrCount = 0;
            while (1 == 1)
            {
              int delay = 500 + rnd.Next(40);
              Thread.Sleep(delay);
              ticks += (uint)delay;

              SensorPayload p = new SensorPayload();
              p.Type = "hrm";
              p.Data.Add("bpm", (ushort)(70 + rnd.Next(20)));
              p.Data.Add("ticks", (ushort)(ticks % 65536));
              SensorMessageReceived(null, p);

              pedalRotations += 1;
              p = new SensorPayload();
              p.Type = "spcd";
              p.Data.Add("wheelTicks", (ushort)((uint)(0.6 * ticks) % 65536));
              p.Data.Add("wheelRotations", (ushort)(pedalRotations % 65536));
              p.Data.Add("pedalTicks", (ushort)(ticks % 65536));
              p.Data.Add("pedalRotations", (ushort)(pedalRotations % 65536));
               SensorMessageReceived(null, p);
               p = new SensorPayload();
               pwrCount++;
               p.Type = "power";
               p.Data.Add("power", (ushort)(170+rnd.Next(20)));
               p.Data.Add("powerCount",1);
               SensorMessageReceived(null, p);

            }
              }
              else
              {
            Device UsbStick = new Device();
            UsbStick.Initialise();
            Sensor hrm = new HRMSensor(UsbStick);
            Sensor speedCadence = new SpeedCadenceSensor(UsbStick);
            hrm.SensorMessage += new SensorMessageHandler(SensorMessageReceived);
            speedCadence.SensorMessage += new SensorMessageHandler(SensorMessageReceived);

            _pollServer = new Timer(SendDataToServer, null, 2000, POLL_INTERVAL);

            UsbStick.Start();
              }
              //
        }
Example #2
0
 public PowerSensor(Device device)
     : base(device)
 {
     ChannelNumber = 1;
     TransmissionType = 0;
     DeviceNumber = 0;
     DeviceType = 11;
     Period = 8182;
     RadioFrequency = 57;
 }
Example #3
0
 public HRMSensor(Device device)
     : base(device)
 {
     ChannelNumber = 1;
     TransmissionType = 0;
     DeviceNumber = 0;
     DeviceType = 120;
     Period = 8070;
     RadioFrequency = 57;
 }
Example #4
0
        private const ushort MULTI_TICK_THRESHOLD = 2; // equivalent to 500RPM!

        #endregion Fields

        #region Constructors

        public SpeedCadenceSensor(Device device)
            : base(device)
        {
            ChannelNumber = 2;
            TransmissionType = 0;
            DeviceNumber = 0;
            DeviceType = 121;
            Period = 8086;
            RadioFrequency = 57;
        }
Example #5
0
 public Sensor(Device device)
 {
     _processor = new SensorProcessor(this);
     _processor.Device = device;
     device.AddSensorProcessor(_processor);
 }