/// <summary> /// This is just for simulate the stop and reset the code. /// Delete this is a option... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAlarm_Click(object sender, EventArgs e) { Timer.times.Stop(); Timer.times.Elapsed -= ConnectionFactor; SetPortAndBaud.SendOnlySingleCommand("8"); SetPortAndBaud.ClosePort(); }
/// <summary> /// Finish: 25.03.2016 /// See if any returnet value from pir and temperatur triggers alarm /// if they do, return the command line to interface for communication to arduino. /// if not any alarm, then return "1" as default. /// </summary> /// <param name="auto"></param> public static void AlarmTriggerCheck(SetPortAndBaud auto) { var TemperatureResult = CheckTemperatureValue(); var PirResult = CheckPirValue(); if (PirResult == 1 && TemperatureResult == 2) { AlarmCommandoStatus = ("2"); //Alarmstatus: Pir and Max temperatur } else if (PirResult == 1 && TemperatureResult == 3) { AlarmCommandoStatus = ("3"); //Alarmstatus: Pir and Min temperatur } else if (PirResult == 1) { AlarmCommandoStatus = ("4"); //Alarmstatus: Pir } else if (TemperatureResult == 2) { AlarmCommandoStatus = ("5"); //Alarmstatus: Max temperatur } else if (TemperatureResult == 3) { AlarmCommandoStatus = ("6"); // Alarmstatus: Min temperatur } else { AlarmCommandoStatus = ("1"); //Alarmstatus: No alarm given } ArduinoValueList.Clear(); }
private void btnGetValue_Click(object sender, EventArgs e) { Timer.Intervall = 2; // Set the Main code intervall Alarm.SetTempLimit(max, min); // Temp Max and Min SetPortAndBaud.SetPortAndValue(9600); // Set Port and baud to serialport Alarm.EnablePirDetectorSettings(true); //Enable Pir Detector Timer.times.Interval = Timer.GetTimerIntervall(); // Intervall for Main code Timer.times.Elapsed += ConnectionFactor; //Sets after the intervall, Runs the main code SetPortAndBaud.NoArduinoConnection += EventHandlerForNoConnection; //Call event for No connection to arduino if (SetPortAndBaud.IfNoPortIsSett) { Timer.times.Start(); // starts the main code timer } }
/// <summary> /// This is just for simulate the clear funksjon both c# and arduino /// with the use of command: 7 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtClear_Click(object sender, EventArgs e) { txtShow.Clear(); SetPortAndBaud.SendOnlySingleCommand("7"); SetPortAndBaud.ClosePort(); }
/// <summary> /// Finish: 22.03.2016 /// Inheritate from Class SetPortAndBaud /// Sends the command to arduino to get data string. /// Get the result string back, and send it to process. /// </summary> /// <param name="command"></param> /// <param name="Port"></param> public static void MainConnectionToArduino(string command, SetPortAndBaud port) { SplittTekst(port.SendCommandToArduino(command)); }