GET request on automation

6 years 9 months ago #2155 by eliobou
Replied by eliobou on topic GET request on automation
I've got the same errors :

Error CS1519 in line 1 column 9, Unexpected symbol `using' in class, struct, or interface member declaration
Error CS1519 in line 1 column 17, Unexpected symbol `;' in class, struct, or interface member declaration
Error CS1519 in line 2 column 16, Unexpected symbol `;' in class, struct, or interface member declaration
Error CS1519 in line 3 column 17, Unexpected symbol `;' in class, struct, or interface member declaration
Error CS1519 in line 4 column 18, Unexpected symbol `;' in class, struct, or interface member declaration

Please Log in or Create an account to join the conversation.

6 years 9 months ago #2159 by hjfabius
Replied by hjfabius on topic GET request on automation
You should not use any "using" statement.

Your code should be something similar to:
public void Setup()
{   
    EventHelper.ModuleChangedHandler((o, m, p) =>
    {    
      if (m.Domain == Domains.VIRTUAL && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue" && p.Value == "1") {
        System.Net.WebRequest request = System.Net.WebRequest.Create("http://website.com");
      }
    });
}

public void Run()
{
}

Please Log in or Create an account to join the conversation.

6 years 9 months ago #2160 by eliobou
Replied by eliobou on topic GET request on automation
I finally came to this code that doesn't send me any error when compiling.

public void Setup()
{ 
}

public void Run()
{
  EventHelper.ModuleChangedHandler((o, m, p) =>
    {    
      if (m.Domain == Domains.VIRTUAL && m.Address == "N3S0" && p.Property == "Sensor.DigitalValue" && p.Value == "1") {
        /*System.Net.WebRequest request =*/
        System.Net.WebRequest.Create("http://website.com");
      }
      
      return true;
    });
}

The problem now is that nothing happen when I set the switch to ON. I don't know what is the problem I will keep searching.

Please Log in or Create an account to join the conversation.

6 years 9 months ago #2163 by hjfabius
Replied by hjfabius on topic GET request on automation
I'm not sire how you configura your automation, but putting the code in run will be equivalent to create one additional event handler at each execution. I'm not sure it really make sense.

In terms of behavior, your code does not do anything on the server, so even if it's working fine, you will not know it.

I suggest to add some debug string like
		Console.WriteLine("step 1 executed");  
.

Once done you stop EasyIoT service and you run it by the command line. Every time your command is executed, your string will be print on the command line.

Please Log in or Create an account to join the conversation.

6 years 9 months ago #2168 by eliobou
Replied by eliobou on topic GET request on automation
I've put the line of code that you were suggested and there is effectively no output on the command line. My configuration should be the problem.
I've created a node in virtual, it's GENERIC type, it's configured as a "digital output (DO)". In the parameter the name is Sensor.DigitalValue.
In automation the program is enabled and the cron setting is "* * * * *".

Please Log in or Create an account to join the conversation.

6 years 9 months ago #2170 by hjfabius
Replied by hjfabius on topic GET request on automation
With Cron setting * * * * * you will have your code executed every minute. Are you sure is what you really want? I believe does not make sense create a new event handler every minute. You can just create once at startup without the usage of Cron.

Try removing your webrequest code and just make the console. On top you move from run function to setup and in Cron configuration you leave it empty.

When you will save, you should see in the console our output string...

If it's not the case you have something wrong somewhere else.

Please Log in or Create an account to join the conversation.

Time to create page: 0.238 seconds

Forum latest

  • No posts to display.