Showing results 1 to 8 of 8

Thread: API for displaying weather forecast in the HMI

  1. #1
    Join Date
    30.05.2013
    Posts
    119

    Default API for displaying weather forecast in the HMI

    Dear Support Team,

    Please let us know if you know any interface to get 7 Days weather forecast of desired location from the internet (or any service provider). We would like to display this on the HMI.


    Best Regards,
    Navaneet.

  2. #2
    Join Date
    08.10.2007
    Posts
    35

    Default Re: API for displaying weather forecast in the HMI

    Hello,

    you could try to use the HTML MDI window to display any weather forcast services available through the internet.

  3. #3
    Join Date
    30.05.2013
    Posts
    119

    Default Re: API for displaying weather forecast in the HMI

    Hi,

    Can you please explain how do we use HTML MDI window in our Zenon Runtime screen. I attached here one sample screen. Please see the red highlighted part, Here we put the static images and values. It will be the weather forecast data from internet.
    Kindly look at the snap and help us to do this.

    Best Regards,
    Navaneet.
    Attached Thumbnails Attached Thumbnails SNAP-1.jpg  

  4. #4
    Join Date
    30.05.2013
    Posts
    119

    Default Re: API for displaying weather forecast in the HMI

    Hi...

    Please any one can tell me, whether displaying "weather forecast" in Zenon runtime from internet is possible or not.

    Best Regards,
    Navaneet.

  5. #5
    Join Date
    13.08.2013
    Posts
    57

    Default Re: API for displaying weather forecast in the HMI

    Well in general it is possible but you have to implement the communication/webservice logic yourself in in C# and Visual Studio.
    So first step would be to import a Service reference (Reference->Service Reference put it in the endpointaddress of the webservice of your choice) this will get you an Client assembly/refernce of the webservice of your choice.
    Then you need to implement the Client e.g.
    static ClientHandler instance;
            BasicHttpBinding Binding = new BasicHttpBinding();
            NavClient.GNATEST_PortClient client = null;
            static String ENDPOINTADDRESS = "http://localhost:7047/THEWEBSERVICEOFYOURCHOICE";
    
            /// 
            /// Valid Constructor, Endpointaddress of  Webservice(which the client connects to)
            /// 
            /// Address to connect to
            private ClientHandler(string EndpointAddress)
            {
                try
                {
                    Binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                    Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                    client = new NAMESPACEOFWEBSERVICE.TEST_PortClient(Binding, new EndpointAddress(EndpointAddress));
                    client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation;
    
                }
                catch (Exception ex)
                {
                    throw new Exceptions.ClientInitFailedException();
                }
            }
            /// 
            /// gets Instance of Client, since client is Singelton
            /// 
            /// Instance of Client
            static public ClientHandler getInstance()
            {
                if (instance == null)
                {
                    throw new Exception("Client not created");
                  ;
                }
                else
                {
                    return instance;
                }
            }

    Also in this class you can now start a requests,
     public int TransferData(NAMESPACEOFWEBSERVICE.WEBSERVICEInterface zInterface)
            {
                try
                {
    
                    int TransactionID = 0;
                    TransactionID = client.TransferData(ref zInterface);
                    //zInterface.ZenonTransaction[0].TransactionID = TransactionID;
                    return TransactionID;
                    // return client.TransferData(ref zInterface); ;
    
                }
                catch (Exception ex)
                {
                    DebugLog.getinstance().CreateLogEntry("Client failed");
                    DebugLog.getinstance().CreateLogEntry(ex.Message);
                    return 0;
                }
               
            }

    Note that you attach a reference of zInterface to the request, this Interface implements only notify
     /// 
        /// Interface implemented by the RuntimeInterface and the WorspaceInterface, takes care that Data which is received by the Webhost is mapped to the right Interface
        /// 
        public interface zInterface
        {
            void Notify(object Data);
        }
    Another class which implements this Interface now receive the Data on notify, in my case it directly maps it to the Variables in zenon


    public void Notify(object Data)
            {
                DebugLog.getinstance().CreateLogEntry("Received on Interface");
               // zAdapt.MappeReceivedToVariables(Data);
                zRuntimeAdapter.getInstance().MappeReceivedToVariables(Data);
                DebugLog.getinstance().CreateLogEntry("Map executed");
            }


    In MappedReceivedToVariables(Data) I parse the object to the Datatype of the webservicecontract, an set specific zenon Variables according to the values




    Best regards
    Sigi

  6. #6
    Join Date
    30.05.2013
    Posts
    119

    Default Re: API for displaying weather forecast in the HMI

    Hi Sigi,

    Thank you. I will work and get back to you, if I need any more help.

    Best Regards,
    Navaneet.

  7. #7
    martins Gast

    Default Re: API for displaying weather forecast in the HMI

    hey,

    another thing you could do would be the usage of a WPF - like this one here:

    http://www.codeproject.com/Articles/...PF-OpenWeather

    Make a User Control out of it and instance it in an otherwise empty XAML.

    best regards,
    Martin

  8. #8
    Join Date
    30.05.2013
    Posts
    119

    Default Re: API for displaying weather forecast in the HMI

    Hi Martin,

    Thank you for your guidance, Let me to try, if I have any further doubt, I get back to you.

    Best Regards,
    Navaneet.

Similar Threads

  1. API Interfacing in Zenon
    By navaneet in forum VBA
    Replies: 10
    Last Post: 13th October 2014, 11:35
  2. API Interfacing with Zenon
    By navaneet in forum VSTA
    Replies: 0
    Last Post: 29th September 2014, 08:17
  3. Hmi
    By arueger in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 5
    Last Post: 20th August 2014, 10:35
  4. API-Zugriff auf Function-Filter
    By stefan.maus in forum VSTA
    Replies: 10
    Last Post: 17th October 2012, 11:31
  5. displaying @ symbol in text box
    By mattsd in forum zenon Service Engine Supervisor
    Replies: 2
    Last Post: 2nd April 2008, 11:04

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •