public void Start() { while (alive) { Thread.Sleep(1000); SerialDataHandler.getInstance().RequestStatus(); } }
public static void Handle(byte[] msg) { if (msg != null) { Console.WriteLine(BitConverter.ToString(msg)); SerialDataHandler.ReceiveData(msg, SerialParseProc); } }
private void OnTimerTick(object source, ElapsedEventArgs args) { //Console.WriteLine("Tick"); SerialDataHandler.getInstance().RequestStatus(); if (dataRequested) { SendMessage(ServerCommands.SendBikeData(latestBikeData)); //Console.WriteLine("Tock"); } }
public static void Handle(byte[] msg) { if (msg != null) { Logger.Debug("msg不为空"); SerialDataHandler.ReceiveData(msg, SerialParseProc); } else { Logger.Debug("msg为空"); } }
private void StartCourse(BikeDataPackage bdp) { DateTime newBikeTime = new DateTime(1970, 01, 01, 00, (int)Math.Floor(int.Parse(bdp.time) / 60d), int.Parse(bdp.time) % 60); SerialDataHandler.getInstance().ResetWithVariables(int.Parse(bdp.power), Convert.ToInt32(newBikeTime.Minute), Convert.ToInt32(newBikeTime.Second), (int)(double.Parse(bdp.distance) * 1000)); dataRequested = true; //VRHandler.getInstance().SetupScene(400, 400); // Set variables // Start sending variables // Setup VR }
public Connection(string ip, int port) { dataRequested = false; SerialDataHandler.getInstance().AddSubscriberToHandler(this); ConnectToServer(ip, port); latestBikeData = new BikeDataPackage("1970-01-01-00:00:00", "0", "0", "0", "0"); dataRequestTimer = new System.Timers.Timer(100); dataRequestTimer.Elapsed += OnTimerTick; dataRequestTimer.AutoReset = true; dataRequestTimer.Enabled = true; dataRequestTimer.Start(); client.GetStream().Flush(); SendMessage(ServerCommands.ClientType()); }
static void Main(string[] args) { // The IP Address of the Server to connect to Console.WriteLine("--- Setting up VR ---"); VRHandler.getInstance().SetupScene(400, 400); Console.WriteLine("--- VR scene loaded succesfully ---"); Console.WriteLine(""); Console.WriteLine("--- Setting up Bicycle ---"); SerialDataHandler.getInstance().InitializeBike(_BIKE_MODE); VRHandler.getInstance().StartBikePoller(); Console.WriteLine("--- Bicycle setup succesful ---"); Console.WriteLine(""); Console.WriteLine("--- Connecting to Remote-Healthcare server ---"); //Connection con = new Connection("145.49.2.246", 6666); Connection con = new Connection(_SERVER_IP, 6666); Console.WriteLine("--- Connected sucesfully to Remote-Healthcare server ---"); Console.ReadLine(); }
public MainController() { DataHandler = new SerialDataHandler(); TaskManager = new Tasker(DataHandler); }
private void WriteData(Rule rule, Value value) { var controller = new CommunicatorController(); var comm = controller.GetAllCommunicators().FirstOrDefault(com => com.Id == rule.Action.CommunicatorId); if (comm == null) return; DataHandler handler = null; switch (comm.Type) { case CommunicatorType.FlatFile: handler = new FlatFileHandler((FileCommunicator)comm,rule,value); break; case CommunicatorType.Serial: handler = new SerialDataHandler((SerialCommunicator)comm,rule,value); break; case CommunicatorType.Database: handler = new DatabaseHandler((DatabaseCommunicator)comm,rule,value); break; default: throw new ArgumentOutOfRangeException(); } }
private void SetPower(int increment) { int latestbikepower = ((int.Parse(latestBikeData.power) - 25) / 4); SerialDataHandler.getInstance().SetPower(latestbikepower + increment); }
private void ClientGUI_Load(object sender, EventArgs e) { SerialDataHandler.getInstance().InitializeBike(1); VRHandler.getInstance().SetupScene(400, 400); }