示例#1
0
 public void setBike(bicycle bikeIn)
 {
     groupBox1.Text        = String.Format("Bicycle {0}", bikeIn.bikeIndex);
     txtVoltageOffset.Text = bikeIn.voltageOffset.ToString();
     txtVAndP.Text         = bikeIn.lastPowerReadingA + " A , " + bikeIn.lastPowerReadingW + " W";
     txtRawValue.Text      = bikeIn.lastRawValue.ToString();
 }
示例#2
0
        public void addBicycle(bicycle toAdd)
        {
            bikes.Add(toAdd);
            toAdd.onNewPowerReading += (a, b) => this.Invalidate();

            this.Invalidate();
        }
示例#3
0
        public void displayBicycle(bicycle sender, DateTime timestamp)
        {
            lblPower.Text     = sender.lastPowerReadingA.ToString("F") + " A";
            powerMeter1.value = (int)sender.lastPowerReadingA;

            if (powerMeter1.value <= 0)
            {
                isIdle = true;
            }
            else
            {
                isIdle = false;
            }
        }
示例#4
0
        public Form1()
        {
            InitializeComponent();

            // Load our bicycles from our application config (user.config), and then init them, which will configure the LJ ready for use.
            bicycles = new bikeSettings().bikes.ToArray();
            if (bicycles.Length == 0)
            {
                int bikeCount = 20;
                bicycles = new bicycle[bikeCount];
                for (int index = 0; index < bikeCount; index++)
                {
                    bicycles[index] = new bicycle(index + 1, "Test", 0);
                }
            }

            int n = 0;

            foreach (bicycle bike in bicycles)
            {
                bike.bikeIndex = n++;     // FIXMEEEE
                bike.postXMLDeserialisation();
            }

            // Wire up events
            foreach (bicycle bike in bicycles)
            {
                bike.onNewPowerReading = updateBikeView;
            }

            foreach (bicycle bike in bicycles)
            {
                powerMeterForm.addBicycle(bike);
                ctlBargraph1.addBicycle(bike);
            }

            // Now the bicycles are configured, we can start the timer, which will poll and update controls.
            // Comment this out if you have no LabJack
            //tmrPollLJ.Enabled = true;
        }
示例#5
0
        private void updateBikeView(bicycle sender, DateTime timestamp)
        {
            // Update total power
            double totalCurrent = bicycles.Sum(x => x.lastPowerReadingA);

            lblTotalCurrent.Text = "Total power: " + (int)totalCurrent + " A";
            powerMeter1.value    = (int)totalCurrent;

            // update the fastest bicycle
            double highest = bicycles.Max(x => x.lastPowerReadingA);

            foreach (cycler thisBike in bicycleControls)
            {
                if (thisBike.cyclistPowerSource.lastPowerReadingA == highest && !thisBike.isFastest)
                {
                    thisBike.isFastest = true;
                }
                if (thisBike.cyclistPowerSource.lastPowerReadingA != highest && thisBike.isFastest)
                {
                    thisBike.isFastest = false;
                }
            }
        }
示例#6
0
        public void addBicycle(bicycle toAdd)
        {
            bikeDetail detail = new bikeDetail();

            detail.Top  = nextBikePosY;
            detail.Left = nextBikePosX;
            Controls.Add(detail);
            detail.Show();

            toAdd.onNewPowerReading      += (bike, timestamp) => detail.setBike(bike);
            detail.onOverrideValueChange += (x) => toAdd.onRawData(x);
            detail.onOffsetChange        += (x) => toAdd.voltageOffset = x;

            nextBikePosX += detail.Width;
            if (nextBikePosX > detail.Width * 2)
            {
                nextBikePosX  = 0;
                nextBikePosY += detail.Height;
            }
            this.Width  = (detail.Width * 3) + 10; // FIXME: why +10?
            this.Height = nextBikePosY + detail.Height + 100;

            detail.setBike(toAdd);
        }