DEVICES DATA TO WEB BROWSER


Recommended Posts

  • 3 weeks later...

Your best bet would be to use a service such as DAQConnect.com to do this.  With that product you'd have to create separate HMI screens for the web, but they will work more efficiently and across all devices.

Alternatively, you could program DAQFactory to take screenshots of pages, then upload them to a webserver.  Sending commands back to DAQFactory would be slightly harder, but is best implemented using a pull mechanism, meaning DAQFactory queries the server at some interval to see if there are commands to perform.  You do not want to open up the system running DAQFactory to the Internet as that is just asking for security problems.  Not because DAQFactory is more insecure than anything else, but because opening up the system to the Internet exposes the system to attacks on all levels, the most likely being on the OS and probably DoS type attacks (even if they are unintentional). 

Link to comment
Share on other sites

  • 3 months later...

Screenshots are done with:

page.capture()

Uploading can be done through the FTP. commands, or possibly other solutions (shell commands?).  Depends on what you are doing.

Download data from the web is done with:

http.get()

Note that most of these functions require DAQFactory Pro.

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Not sure where you are going with this.   The Real Time Web feature only works with the DAQConnect service and their servers.  You can't point it to your own computer as you don't have a DAQConnect server.

How did you get the Object Not Found errors?  What Help file were you trying to look at?

Link to comment
Share on other sites

  • 4 years later...

I have a webserver running locally that I'm trying to hit using HTTP.Get("127.0.0.1", "/optimize", 5000) or HTTP.Get("localhost", "/optimize", 5000), but I keep getting "HTTP Error: A connection with the server could not be established." I can access the server with a web browser (127.0.0.1:5000/optimize or localhost:5000/optimize). Is there a reason why DF can't find localhost, or am I doing something wrong?

Link to comment
Share on other sites

I can't say.  Your syntax looks fine.  HTTP.Get() calls a Windows API function and the error message you are seeing is coming directly from that function.  I am thinking maybe there is some sort of firewall setting that is making it not work?  You could try just creating an Ethernet Client connection and see if you can get a response.  Usually, once you have connected to the IP address and port, all you need to send is:

GET /optimize HTTP/1.1\013\010\013\010

where \013\010 is carriage return / line feed and what you would type in the Monitor Window.

If you get "Port is busy" then DAQFactory couldn't open a socket to the server and I would say you definitely have some sort of security setting that is allowing the browser to access it, but not DAQFactory.

 

Link to comment
Share on other sites

  • 2 weeks later...

Still scratching my head here. If I send GET /optimize HTTP/1.1\013\010\013\010 I correctly receive HTTP 200.

If I deliberately send something wrong EG GET /abc HTTP/1.1\013\010\013\010 I correctly get a 404 not found.

Same for GET HTTP/1.1\013\010\013\010; 404 Not Found

But HTTP.Get("127.0.0.1", "/optimize", 5000) gives the "a connection to the server could not be found" error. There is also no traffic captured on wireshark

What is strange is HTTP.Get("127.0.0.1", "", 5000) does correctly return a 404 error and I can see it in wireshark.

Does HTTP.Get() do any formatting before sending to windows?

Link to comment
Share on other sites

Another question if you will entertain me. I'm using a DLL at the moment to get around the issue, but it is a bit inconvenient that DF blocks while the function is running (i have to call it fairly regularly, and takes around 5 seconds to compute). Is there a way to call DLL functions asynchronously?

"DLLGlue.dll":

#include <stdlib.h>

            extern "C"
            {
                __declspec(dllexport) char RunApp(char *command)
                {
                    return system(command);
                }
            }   

       

Then in DF:

extern(OPT.OptimiserLocation + "DLLGlue.dll", "char RunApp(string)", "OptRunApp", "stdcall")

OptRunApp("cmd /C python " + chr(34) + OPT.OptimiserLocation + "query.py" + chr(34))

Link to comment
Share on other sites

First part: http.get() just uses the OpenURL() function of the MFC CInternetSession class.  It is a pretty dead simple wrap of this function.  https://learn.microsoft.com/en-us/cpp/mfc/reference/cinternetsession-class?view=msvc-170.  DAQFactory will automatically add http:// in front.  It will also add :5000 to the end.  For the path, if you don't start with / it will add it for you.  Note you should see an error message in the command alert if it fails.  Are you not getting one?

As to the second question, first, are you just trying to run a command line?  If so, why don't you just use system.shellExecute()?  There is no reason to right a DLL.  System.ShellExecute() does not block, which, actually is the only reason I can think that you would want to create a DLL to wrap it.  There are cases when you want to run a shell program, and then likely you piped the result to a file that you can then read into DAQFactory.  If you don't block you have to use other tricks to make sure it is complete.

Anyhow, to your original question, you can make pretty much anything non-blocking in DAQFactory by simply putting it in its own sequence or thread.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.