- Posts: 3
- Thank you received: 0
Please Log in or Create an account to join the conversation.
nqdanyb wrote: How to shutdown raspbian when a virtual button hit is pressed? please help me!
Please Log in or Create an account to join the conversation.
/*
This code is running one time when program is enabled
*/
public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
// read switch status
ModuleParameter par = ModuleHelper.GetProperty(Domains.VIRTUAL, "N1S0", "Sensor.DigitalValue");
if (par.Value == "1")
{
System.Diagnostics.Process.Start("sudo shutdown -h now","");
}
return true;
});
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
}
Please Log in or Create an account to join the conversation.
nqdanyb wrote: Thank you for the reply, i tried but it did not work. Here is my program:
Sympathy for me because I am a new beginner/* This code is running one time when program is enabled */ public void Setup() { EventHelper.ModuleChangedHandler((o, m, p) => { // read switch status ModuleParameter par = ModuleHelper.GetProperty(Domains.VIRTUAL, "N1S0", "Sensor.DigitalValue"); if (par.Value == "1") { System.Diagnostics.Process.Start("sudo shutdown -h now",""); } return true; }); } /* This code is running periodicaly when program is enabled. Cron job detirmine running period. */ public void Run() { }
System.Diagnostics.Process p1 = new System.Diagnostics.Process ();
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
p1.StartInfo.FileName = "sudo";
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.Arguments = "shutdown now";
p1.StartInfo.RedirectStandardInput = true;
p1.Start ();
Please Log in or Create an account to join the conversation.
/*
This code is running one time when program is enabled
*/
public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
// read switch status
ModuleParameter par = ModuleHelper.GetProperty(Domains.VIRTUAL, "N1S0", "Sensor.DigitalValue");
if (par.Value == "1")
{
System.Diagnostics.Process p1 = new System.Diagnostics.Process ();
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
p1.StartInfo.FileName = "sudo";
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.Arguments = "shutdown -h now";
p1.StartInfo.RedirectStandardInput = true;
p1.Start ();
}
return true;
});
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
}
Please Log in or Create an account to join the conversation.