在西门子s7网络服务器中显示带有JSON结构的几个标签 [英] Show several tags with JSON structure in Siemens s7 webserver

查看:181
本文介绍了在西门子s7网络服务器中显示带有JSON结构的几个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有集成网络服务器的西门子S7-1200 PLC。
我想使用javascript在网页上显示来自PLC的多个模拟值。使用JSON结构添加和展示多个标签?我已经完成了以下工作:
- 更新了JavaScript与一个建议的代码
- 更新了脚本读取的htm文件



但是我不知道我是否已经完成了这个正确的操作,然后如何调用$

这是我想要显示数据的表格:

 < table> 

< tr>
< td class =static_field>Nivå[m]:< / td>
< td class =output_field>< label id =HMI_skalert> 0< / label>< / td>
< / tr>

< tr>
< td class =static_field> Masse [tonn]:< / td>
< td class =output_field>< label id =Tank1_masse> 0< / label>< / td>
< / tr>

< / table>






脚本:

 < script type =text / Javascript> 
$(document).ready(function(){
$ .ajaxSetup({cache:false});
setInterval(function(){
$ .getJSON(IOwebserver .htm,function(result){

HMI_skalert = result.HMI_skalert
Tank1_masse = result.Tank1_masse

});
},1000) ;
});
< / script>






文件:
IOwebserver.htm

  {
:=webdata.HMI_skalert:,
:=webdata.Tank1_masse:

非常感谢。

解决方案

我想你应该看看这篇文章... https://api.jquery.com/jquery.getjson/



<您没有在IOwebserver.htm文件中返回JSON密钥。


$ b

:=webdata.HMI_skalert: - >使用 AWP命令的JSON对象的值这种情况下..
:=Name_of_DataBlock.variable: - >符号(:=)和(:)是Simatic WebServer中使用的AWP命令的边界



因此,请尝试重新制作此文件:

  {
HMI_skalert::='webdata'。 HMI_skalert:,
Tank1_masse::='webdata'.Tank1_masse:
}

如果这不起作用,请尝试用1(')替换撇号dobule quotes()。例如,我使用间隔加载XML文件为Simatic S7-S1200 WebServer加载57个变量。欲了解更多信息,请联系我。

I am using a Siemens S7-1200 PLC with integrated webserver. I want to show multiple analog values from the PLC in the webpage using javascript. With one tag it works great, but how do I add and present multiple tags using JSON structure?

I have done the following: - Updated the javascript with a suggested code - Updated the htm file that the script reads from

But I do not know if i have done this correct and how do I then call for the different variables.

THIS IS THE TABLE I WANT TO DISPKLAY THE DATA IN:

    <table>

<tr>
    <td class="static_field">Nivå [m]:</td>
    <td class="output_field"><label id="HMI_skalert">0</label></td>     
</tr>

<tr>                    
    <td class="static_field">Masse [tonn]:</td>
    <td class="output_field"><label id="Tank1_masse">0</label></td>
</tr>

</table>


SCRIPT:

<script type="text/Javascript">
    $(document).ready(function(){
    $.ajaxSetup({ cache: false });
    setInterval(function() {
            $.getJSON("IOwebserver.htm", function(result){

               HMI_skalert= result.HMI_skalert  
                Tank1_masse=result.Tank1_masse

            });
        },1000);
        });
    </script>


FILE: IOwebserver.htm

{
":="webdata".HMI_skalert:",
":="webdata".Tank1_masse:"
}

Thank you so much.

解决方案

I think you should look on this article... https://api.jquery.com/jquery.getjson/

You haven´t a return key in JSON in IOwebserver.htm file.

":="webdata".HMI_skalert:" -> value of JSON object which use AWP command in this case.. :="Name_of_DataBlock".variable: -> Symbols (:=) and (:) are boundaries of AWP command used in Simatic WebServer

So try to remake this file like this:

{
 "HMI_skalert":":='webdata'.HMI_skalert:",
 "Tank1_masse":":='webdata'.Tank1_masse:"
}

If this will not work try to swap apostrophes dobule quotes (") by one (').

For example I use a interval loading XML file to load 57 variables for Simatic S7-S1200 WebServer. For more information contact me..

这篇关于在西门子s7网络服务器中显示带有JSON结构的几个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆