more G-Labs products

Author Topic: HOW TO Run "Program Code" triggered from "Startup Code"  (Read 820 times)

October 29, 2015, 09:37:31 PM
Read 820 times

teo1969

  • *
  • Information
  • Newbie
  • Posts: 4
Dear, I have a PIR X10 sensor named: "B3" that trigger a C#  program "Startup Code" . I would like to run the code content in  "program code" section, when B3 goes "on".

I develop this code that succesfully read event X10(B3) sensor but i'm not able to run the corresponding "program code" when i recive "B3=on" event.

what 'wrong in my code? .... why when B3 goes "on", and i see my trigger notification, my program code is not executed?

**my startup/trigger code:**
Code: [Select]
When.ModuleParameterChanged((module, parameter) => {
       
        if (module.Is("B3"))
        {
         
          if (parameter.DecimalValue > 0){
              Program.Notify("Event: ON->GO", "execute my program code");
              return true;
  }else{
            Program.Notify("Event OFF: ","do nothing");
                return false;
          }
        }
  return false;
});
Program.GoBackground();

**my Program code:**
Code: [Select]
...
//TODO
Program.Notify("Program Code ","do somethings!!");
...

Many Thx in advance!!
Matteo
« Last Edit: October 29, 2015, 09:46:51 PM by teo1969 »

October 29, 2015, 09:52:51 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
move your current "startup code" to the "program code" and just put a
 
Code: [Select]
Program.Run();

in the startup code.

October 31, 2015, 09:13:51 AM
Reply #2

teo1969

  • *
  • Information
  • Newbie
  • Posts: 4