Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hi All,
In an effort to understand the complexity of having / creating a connected office and integrating this with Thingworx
We decided to use existing devices. Servers and desktops were not too bad an I have found various methods to do this.
Connecting Printers is a bit of a different challenge. For example. Our multifunction office printer is an OKI and has web services.
This is the view via Postman
This is some additional information via web services
The problem with this that the data is unstructured and in tables in html format.
I have created a generic remote thing and a service to pull this data.
Which basically gives me this.
Any ideas of a better approach to this.?
Thanks in advance.
Solved! Go to Solution.
Hi Bryan Kirchner,
As you don't have the option for xml or JSON type of data; this seems good.
Have you tried further to parse this HTML data to get the actual values and store them in ThingWorx properties? If not you can give it a try.
Also, we can use the HTML widget to show this data on ThingWorx Mashup.
Hi Bryan Kirchner,
As you don't have the option for xml or JSON type of data; this seems good.
Have you tried further to parse this HTML data to get the actual values and store them in ThingWorx properties? If not you can give it a try.
Also, we can use the HTML widget to show this data on ThingWorx Mashup.
Thanks for the feedback. The html widget goes a long way to displaying the data in a mashup and is great if the original html is well formatted.
I would like to further parse the html data to get the actual values and store them. Any idea how to achieve that?
Hi Bryan Kirchner,
I have worked with Parsing of xml in ThingWorx but haven't tried parsing HTML in ThingWorx. Per my understanding the normal Javascript code for HTML parsing should work.
Do let me know if you face any issue.
I have used JavaScript code to parse the results.
Its FAR from what i would like and I'm sure there are better was to go about this.
var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: 'http://192.168.2.20/status.htm' /* STRING */,
timeout: undefined /* NUMBER */,
appendHeader: undefined /* BOOLEAN */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};
//var result = Resources["ContentLoaderFunctions"].GetText(params).replace(/<(?:.|\n)*?>/gm, '');
test = Resources["ContentLoaderFunctions"].GetText(params).replace(/<(?:.|\n)*?>/gm, '');
//var result=test;
//var result=test.search("Location"); //doesnet work
var result1=test.replace(/-->| |;|Tray|document.write|document.open|document.close|((''))|for|else|if|status|!|c_name|ipver|Address *|IPv6|"IPv4"/g,""); // this is a good way to strip out the html and all the other stuff but its messy.
var result= result1.substr(270, result1.length-1300); //this takes the result of the strig above and trims it from the beginning and the end.
Will continue, next step will be to somehow separate the info and use that in thingworx
Update if you are interested.
So after trying endlessly to find some sort of example javascript code to strip out the useless html code I gave up.
Clearly if you want to do do anything beyond the very simple in composer, you need to know how to write code like a pro... (clearly not my area)
So not all is lost. I have found that if you want to "connect" your iot enabled devices you need to employ the services of above said programmer.
I looked at other ways to get this information and in 30 seconds i was able to get the EXACT information i wanted using a excel web query.
Is there anyway to do something similar with thingworx?
I have had time to revisit this Area and I'm still struggling to get useful data from this "file"
Using the answer I have a much cleaner view of the page. Unfortunately the information cannot be logged.
I cant find any way using javascript to extract this info. SO I was wondering if there is a way to take the data in the mashup and somehow process that?
Any suggestions would be appreciated.
Would Kepware be a solution to this??
Hi, Bryan
Could you do a Wire shark capture of the postman request for the countsum and attach a pcap showing the request and response. I may be able to build you an example using KEPServerEx's UCON driver that will send the post and parse the response for you.
Hi Rob,
I have set up Kepware on my Test system and have successfully managed to connect using the snmp.
I found a "mib" that I just imported and and now I have multitudes of information.
All i have to do now is read that info into thingworx. (time to start reading help files)
The good part is i now know the effort required to achieve different levels of integration.
thanks to all so far.
Bryan