예제 #1
0
        /// <summary>
        ///     On every interval of the timer send new power data to the bike and change the bike data on the panels
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void tickingTimer()
        {
            threadStop = false;
            while (!threadStop)
            {
                Console.WriteLine("SCENE LOADED " + sceneLoaded);
                if (sceneLoaded)
                {
                    Console.WriteLine("TIMER TICK " + Process.GetCurrentProcess().Threads.Count);
                    if (changeDaytime)
                    {
                        VRtime.setTime(VRtime.currentTime + 0.01);
                    }
                    Thread.Sleep(30);

                    if (bikeSet)
                    {
                        if (false)
                        {
                            var h = 40;
                            try
                            {
                                position = node.getPosition("Bike");
                                if (position != null)
                                {
                                    h = vrt.getHeight(position[0], position[1]);
                                }

                                Thread.Sleep(30);
                            }
                            catch (Exception exp)
                            {
                                Console.WriteLine("ERROR POSITION GETTING " + exp);
                            }
                            Console.WriteLine("Bike pos " + string.Join(",", position));
                            Console.WriteLine("Bike height " + h);
                            if (h != 0)
                            {
                                if (h >= lh)
                                {
                                    powerA += 10;
                                }
                                if (h <= lh)
                                {
                                    powerA -= 10;
                                }
                                lh = h;
                                if (powerA > 0)
                                {
                                    bike.connector.sendData("PW " + powerA);
                                }
                            }
                        }
                        //bikeUUID = node.getUUID("Bike");

                        if ((bikeUUID != null) && (oldRpm != rpm))
                        {
                            node.updateSpeed(bikeUUID, rpm * 0.1);
                        }
                        oldRpm = rpm;

                        var minutes = (int)timeD / 60;
                        var seconds = (int)timeD % 60;
                        var time    = minutes.ToString("00") + ":" + seconds.ToString("00");
                        VRr.routeSpeed(cameraUUID, rpm / 5);
                        Thread.Sleep(30);
                        //panelUUID = node.getUUID("BikePanel");
                        if (panelUUID != null)
                        {
                            panel.clearPanel(panelUUID);
                            panel.drawTextonPanel(panelUUID,
                                                  "Heartbeat                           " + bpm + " Bpm \\n" +
                                                  "Rotations                            " + rpm + " Rpm  \\n" +
                                                  "Speed                                 " + speed + " Km/h\\n" +
                                                  "Distance                             " + distance + " Km\\n" +
                                                  "Power                                 " + power + " Watt\\n" +
                                                  "Energy                                " + energy + " kJ \\n" +
                                                  "Time                                   " + time + " \\n" +
                                                  "Actual Power                       " + ap + " Watt"
                                                  , 20, 40, 20, 0, 0, 0, 1, "Segoeui");
                            if (newMessage != null)
                            {
                                try
                                {
                                    message3 = message2;
                                    message2 = message1;
                                    message1 = newMessage.Split(':')[3];
                                    if (message1.Length > 28)
                                    {
                                        message2 = message1.Substring(28);
                                        message1 = message1.Substring(0, 28);
                                        if (message2.Length > 28)
                                        {
                                            message3 = message2.Substring(28);
                                            message2 = message2.Substring(0, 28);
                                        }
                                    }
                                    newMessage = null;
                                }
                                catch (Exception ef)
                                {
                                    //Console.WriteLine(ef);
                                }
                            }

                            panel.drawTextonPanel(panelUUID, "Message: ", 80, 175, 20, 0, 0, 0, 1, "Segoeui");
                            Thread.Sleep(30);
                            panel.drawTextonPanel(panelUUID, message1 + "\\n" + message2 + "\\n" + message3, 10, 190, 20,
                                                  0, 0, 0, 1, "Segoeui");
                            Thread.Sleep(30);
                            panel.swapPanel(panelUUID);
                            Thread.Sleep(30);
                        }
                    }
                }
                Thread.Sleep(30);
            }
            Console.WriteLine("----- THREAD STOPPED ----");
        }
예제 #2
0
 private void trackBar1_Scroll(object sender, EventArgs e)
 {
     time = new VRTime(vr);
     time.setTime(trackBar1.Value);
 }