8 Replies Latest reply on May 23, 2017 11:19 PM by bkirchner-2 RSS
    bkirchner-2 Explorer

    Company Printers DashBoard

    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

    printer_oki.PNG

     

    This is some additional information via web services

     

    printer_oki1.PNG

     

    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.

     

    printer_oki2.PNG

     

    Which basically gives me this.

     

    Any ideas of a better approach to this.?

     

    Thanks in advance.

      • Re: Company Printers DashBoard
        Ankit Gupta Ninja

        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.

          • Re: Company Printers DashBoard
            bkirchner-2 Explorer

            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?

             

              • Re: Company Printers DashBoard
                Ankit Gupta Ninja

                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.

                  • Re: Company Printers DashBoard
                    bkirchner-2 Explorer

                    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(/-->|&nbsp|;|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

              • Re: Company Printers DashBoard
                bkirchner-2 Explorer

                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?

                • Re: Company Printers DashBoard
                  bkirchner-2 Explorer

                  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??

                    • Re: Company Printers DashBoard
                      rsharp-2 Newbie

                      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.

                        • Re: Company Printers DashBoard
                          bkirchner-2 Explorer

                          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