• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Webseite für Siemens CPU

Pepper49er

Mitglied
Hallo, ich möchte eine Webseite für eine Siemens CPU erstellen. Dafür benötige ich einen Button(true wenn gedrückt und false wenn losgelassen) In den Siemens Beispielen gibt es solch einen Button nicht. Es werden immer 2 Buttons benutzt. Der "vor" Button übergibt den Wert "1" an den "vor" Button und "0" an den "zurück" Button und der "zurück" Button übergibt "1" an den "zurück" Button und "0" and den "vor" Button (sehr umständlich). In meinem Programmbeispiel wird die AWP Variable '"DB_Motor".Motor_vor' benutzt hiermit will ich einen Motor fahren solange der Button betätigt wird. Leider funktioniert das nicht. Ich weiß die Syntax für diese AWP Variable nicht. In den Siemens Beispielen wird sie wie oben beschrieben angewendet. Hier mein Programm Code:
<!-- AWP_In_Variable Name='"DB_Motor".Motor_vor' -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<script type="text/javascript">
function Vor()
{
"DB_Motor".Motor_vor = 1;
}
</script>
</head>
<body>
<form method="post">
<input type="button" value="vorfahren" onmousedown="Vor(this);">
</form>
</body>
</html>
Vielen Dank im voraus.
 
Werbung:
CPU 1512 TIA Portal

<!-- AWP_In_Variable Name='"OpenValve"' -->
<!-- AWP_In_Variable Name='"CloseValve"' -->


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Userdefined Website - Application Overview</title>
<meta http-equiv="Content-Language" content="en" >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta http-equiv="Content-Script-Type" content="text/javascript" >
<meta http-equiv="refresh" content="1; URL=Overview.htm">
<link rel="stylesheet" type="text/css" href="Stylesheet/siemens_Stylesheet.css"/>
<script src="Script/siemens_script.js" type="text/javascript"> </script>
</head>

<body>

<!-- Header Line -->
<div id="header">
<table border="0" >
<tr>
<td width="650px"><h2><big>TIA Portal V11 <br> Webserver Applikation</big></h2></td>
<td width="300px"><img src="Images/SIEMENS_Logo.PNG"/></td>
</tr>
</table>
</div>
<!-- Header Line End-->

<!-- Navigation -->
<div id="navi">
<ul>
<a href="Start.htm">Plant status</a><br>
<a>Overview Tank</a><br>
<a href="Data.htm">Data</a><br>
<a href="DataOpti.htm">Data optimized</a>
</ul>
</div>
<!-- Navigation End-->

<!-- Data Area -->
<div id="page">

<h3>Overview Tank</h3>

<table border="0" width="550px">
<tr>
<td width="250px" height="200px" rowspan="14" valign="bottom" background="Images\TankExample.PNG"
style="background-repeat:no-repeat; background-position:bottom left">
<img src="Images\blue.png" alt="Level" width="56px" height=":=TankLevelScal:px " style="margin-left:48px; margin-bottom:-3px">
<img src="Images\Valve:="StatusValveCPU":.png" name="Valve" "StatusValveCPU = 0"id="StatusValveCPU" alt="Valve" style="margin-left:70px; margin-right:2px; margin-bottom:12px">
</td>
</tr>
<tr>
<td class="static_field_headline">Data</td><td></td>
<td class="static_field_headline_left">Current Value</td>
</tr>

<tr>
<td class="static_field">Flowrate:</td>
<td class="output_field">:="ActFlowrate":</td>
</tr>
<tr>
<td class="static_field">Tank Level: </td>
<td class="output_field">:="TankLevel":</td>
</tr>
<tr>
<td class="output_field_long" colspan="2"><b><!-- AWP_Enum_Ref Name='"Alarm"' Enum="AlarmValue" -->:="Alarm":</b></td>
</tr>
<tr>
<td class="static_field">&nbsp;</td>
<td class="static_field">&nbsp;</td>
</tr>
<tr>
<td class="static_field_headline">Measurement</td>
<td class="static_field_headline_left">Unit</td>
</tr>
<tr>
<td class="static_field">Tank Level Overflow:</td>
<td class="output_field">:="TankLevelOverflow":</td>
</tr>
<tr>
<td class="static_field">Tank Level Maximum:</td>
<td class="output_field">:="TankLevelMaximum":</td>
</tr>
<tr>
<td class="static_field">Tank Level Midth:</td>
<td class="output_field">:="TankLevelMidth":</td>
</tr>

<tr>
<td class="static_field">Tank Level Minimum:</td>
<td class="output_field">:="TankLevelMinimum":</td>
</tr>
<tr>
<td class="static_field">Tank Level Lack:</td>
<td class="output_field">:="TankLevelLack":</td>
</tr>
<tr>
<td class="static_field">&nbsp;</td>
<td class="static_field">&nbsp;</td>
</tr>
<tr>
<td width="144px" height="21px">
<form method="post" action="">
<input type="submit" value="OpenValve">
<input type="hidden" name='"OpenValve"' size="20px" value="1">
<input type="hidden" name='"CloseValve"' size="20px" value="0">
</form>
</td>

<td width="144px" height="21px">
<form method="post" action="">
<input type="submit" value="CloseValve">
<input type="hidden" name='"CloseValve"' size="20px" value="1">
<input type="hidden" name='"OpenValve"' size="20px" value="0">
</form>
</td>
</tr>
</table>
</div>
<!-- Data Area End-->
</body>
</html>
 
// function to check value
function check()
{
var x = document.getElementById("wert1");
if (x.value >= 1 && x.value <= 10 )
{
return true;
}
else
{
alert ("Enter Flowrate between 1 and 10");
document.getElementById("wert1").value = "";
return false;
}
}
 
Werbung:
Das siemens_script.js bezieht sich auf dies Seite:

<!-- AWP_In_Variable Name='"Start"' -->
<!-- AWP_In_Variable Name='"Stop"' -->
<!-- AWP_In_Variable Name='"Reset"' -->
<!-- AWP_In_Variable Name='"Flowrate"' -->


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Userdefined Website - Application Start</title>
<meta http-equiv="Content-Language" content="en" >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta http-equiv="Content-Script-Type" content="text/javascript" >
<!-- <meta http-equiv="refresh" content="10; URL=Start.htm"> -->
<link rel="stylesheet" type="text/css" href="Stylesheet/siemens_Stylesheet.css"/>
<script src="Script/siemens_script.js" type="text/javascript"> </script>
</head>

<body>

<!-- Header Line -->
<div id="header">
<table border="0" >
<tr>
<td width="650px"><h2><big>TIA Portal V11 <br> Webserver Applikation</big></h2></td>
<td width="300px"><img src="Images/SIEMENS_Logo.PNG"/></td>
</tr>
</table>
</div>
<!-- Header Line End-->
<!-- Navigation -->
<div id="navi">
<ul>
<a>Plant status</a><br>
<a href="Overview.htm">Overview Tank</a><br>
<a href="Data.htm">Data</a><br>
<a href="DataOpti.htm">Data optimized</a>
</ul>
</div>
<!-- Navigation End-->
<!-- Data Area -->
<div id="page">

<h3>Plant status</h3>

<table width="840px" height="100px" border=0>
<tr>
<td width="100%" align="center" height="10%">
<img style="vertical-align: bottom; margin: 0px; height: 50px; width: 50px; " src="Images\Status0:="StartStop":.png"/> <cr>
</td>
</tr>

</table>

<table width="840px" height="100px" border=0>
<tr>
<td align="left">
<form method="post" action="">
<input type="submit" value="Start" style="height: 45px; width: 200px">
<input type="hidden" name='"Start"' value="1">
<input type="hidden" name='"Stop"' value="0">
</form>
</td>
<td align="center">
<form method="post" action="">
<input type="submit" value="Stop" style="height: 45px; width: 200px">
<input type="hidden" name='"Stop"' value="1">
<input type="hidden" name='"Start"' value="0">
</form>
</td>
<td align="right">
<form method="post" action="">
<input type="submit" value="Reset" style="height: 45px; width: 200px">
<input type="hidden" name='"Reset"' size="80" value="1">
</form>
</td>
</tr>
<tr>
<td height="55px">
</tr>
</table>


<h3>Flowrate of tank filling or emptying</h3>
<p>Determine the flowrate of filling or emptying the tank by a number between 1 and 10!</p>

<form method="post" action="" onsubmit="return check();">
<input type="text" id="wert1" name='"Flowrate"' size="2" style="height: 45px; width: 50px; font-size: 21px; text-align: center; padding: 8px;">
<input type="submit" value="Set a new Flowrate" style="height: 45px; width: 200px">
</form>

<p>Actual Flowrate: :="ActFlowrate":</p>

<h3>Filling Level</h3>
<table width="840px" height="100px" border=0>
<tr>
<td width="210px" align="left" height="25px">
<tp><big>Tank Level</big></tp>
</td>
<td width="210px" align="left" height="25px">
<tp><big>:="TankLevelScal": % </big></tp>
</td>
<td width="420px" align="left" height="30px">
<div style=" width: 420px; height:30px; border: solid 1px black; ">
<img style="vertical-align: bottom; margin: 1px; height: 28px; width: :="TankLevelScal":%; " src="Images\blue.png"/>
</div>
</td>
</tr>
</table>
</div>
<!-- Data Area End-->
</body>
</html>
 
Werbung:
Werbung:
Hallo, habe die beiden Seiten in das entsprechende HTML-Verzeichnis der CPU geladen und als Startseite die
"Test.html" angegeben, aber leider wird die Variable "DB_Motor".Motor_vor nicht angesteuert.
 
Werbung:
Auf diesem Screenshot sieht man auf dem linken Bildschirm die Beobachtungstabelle der Variablen während ich auf dem rechten Bildschirm den Button betätige.
 

Anhänge

  • Screenshot (6).png
    Screenshot (6).png
    270,3 KB · Aufrufe: 2
Anftrage:
-----------------------------169226396329638576712782509086
Content-Disposition: form-data; name="\"DB_Motor\"%2EMotor_vor"

1
-----------------------------169226396329638576712782509086--
Antwort: nichts
 
Das wird nicht so einfach sein, da den entsprechenden Ansprechpartner zu finden, aber ich werde das mal probiere.
Wenn man statt einer DB Variable eine einfache Merker Variable nehmen würde, wäre das einfacher?
DB Variable: '"DB_Motor".Motor_vor' Merker Variable: '"Motor_vor"'
 
Werbung:
Hatte leider auch keinen Erfolg. Ich werde mir jetzt mal die Netzwerkanalyse bei einer funktionierenden Siemens Webseite
anschauen, wie da die Variablen übergeben werde.Danach bleibt nur noch der Support.
 
Bei der Siemens Webseite sehen die Variablen so aus:
"Web2Plc".start: "1"
"Web2Plc".stop: "0"
 

Anhänge

  • Screenshot (7).png
    Screenshot (7).png
    496,6 KB · Aufrufe: 1
Hallo, habe vom Siemens Support ein AJAX Demo bekommen, kann aber den Button</> nicht aktivieren. Soll ich den Code mit copy und paste einfügen oder als Datei anhängen?
 
Werbung:
1. Datei demo11_ajax.html
Seite 1
Interessant erscheint mir hier beim Aufruf der Funktion "send_ajax_request('%22VelocityVariables%22.velocity', 'velocityField') das die Gänsefüßchen durch %22 ersetzt wurden.

<!-- AWP_In_Variable Name='"VelocityVariables".velocity' -->
<!-- This AWP-Statement is necessary, if the variable "Velocity" will be written within the HTML page -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>S7-Web2PLC Demo11 - Optimized Visualization of a PLC-Variable (AJAX-Version)</title>

<link rel="stylesheet" type="text/css" href="demo.css">

<script src="ajaxbase.js" type="text/javascript"></script>

<script type="text/javascript">

var g_bPageRequested = false;

// a timer will be started, after one second the funktion OnTimer will be called
function Start()
{
DetermineBrowser();
ForceUpdate(:="VelocityVariables".dynValue:); // immediate initialization of the value visualization
setTimeout("OnTimer()",1000);
}

// The page update11.dat solely consists of a reference to the variable "Dynvalue".
// <colon><equalsign><Variablenname><colon> is the common syntax for variable references.
// Since this page is set "manual" (in AWP_Start_Fragment - statement at begin of the page), a dedicated
// user program within the PCL is triggered when this page is requested and will then defer the HTTP response
// until the variables value has been changed
function OnTimer()
{
if (! g_bPageRequested)
{
g_bPageRequested = true;
// request the update page asynchronously, function UpdateCallback is called if response
// has been received
DoHttpRequest(this, "update11.dat", UpdateCallback, true); // response is javascript
// this asynchronous method does silently update the data within the browser
}
setTimeout("OnTimer()", 200); // the function OnTimer is to be called every 200 ms
}

// update11.dat has been received
function UpdateCallback(obj, response, status) {
var ok;
//Splitting the results
var results = response.split(" ");
//Splitting the results in single signs
var signs = results[0].split("");
var i;
var count = 0;
for (i = 0; i < signs.length; i++) {
//Check if the first signs are numbers
if (true == isNaN(signs)) {
count = count + 1;
}
else {break;}
}
//delete signs which aren't numbers
dynValue = results[0].substr(count, signs.length);

var dynValueInt = parseInt(dynValue);

if (status < 300) {// check HTTP response status
document.getElementById('veloDiv').innerHTML = results[1];
ForceUpdate(dynValueInt); // update with the provided value
g_bPageRequested = false;
setTimeout("OnTimer()", 200); // the function OnTimer is to be called in 200 ms
return;
}
if (status == 503) { // service currently unvailable , server overloaded
ok = confirm(dynValueInt);
} else {
ok = confirm("FAILED: HTTP error " + status);
}
g_bPageRequested = false;
if (ok) {
setTimeout("OnTimer()", 1000); // the function OnTimer is to be called in 1 sec
}
}
// Within the page update11_ajax.html or update11_ajax.js the function ForceUpdate is called with the current value.
// This value (0..255) controls the width of table "table2" within the table "table1"
function ForceUpdate(val)
{
var width, barval;
var tabelem;

tabelem = parent.document.getElementById("bar");
width = tabelem.parentNode.clientWidth;

barval = ((val*width)/256); // convert to percent, Firefox can display % only for integral numbers !
if (barval == 0) barval = 1; // 0 not allowed for IE
tabelem.style.width = Math.floor(barval)+"px"; // set table width

var td = parent.document.getElementById("td1"); // display value numerically
if (td.textContent)
{ // textContent is ok for Firefox, not for IE
td.textContent = val+"";
}
else
{
td.innerHTML = val+"";
}
g_bPageRequested = false;
}




</script>
</head>

<body onload="Start()">

<table class="demohead">
<tr>
<td class="democoltitle">This page demonstrates:</td>
<td class="democoltext" > AJAX, it is used to asynchronously read and update the page.</td>
</tr>
</table>
<hr>

<!--------------------------------------------------------------------------------------------->

<p>
dynvalue:<br>
=> The process value will be changed between 0 and 255 within the PLC.<br>
=> The value is visualized inside the horizontal bar at the bottom.<br><br>
velocity:<br>
=> The fill rate can be adjusted by setting the value inside the box
</p>
<!--------------------------------------------------------------------------------------------->

<hr>
<p>
The update page update11.dat requests the current value of "dynvalue" <br>
</p>
<hr>
<!--------------------------------------------------------------------------------------------->

<p>
<a href="demo11.html">Same demo with iframe</a>
</p>
<!--------------------------------------------------------------------------------------------->

<p>The current velocity of change is <span id="veloDiv">:="VelocityVariables".velocity:</span></p>
<!-- writing of the value "Velocity" requires the AWP_In_Variable - statement at begin of this page -->
<input type="text" id="velocityField" name='"VelocityVariables".velocity' size="6">
<input type="button" onclick="send_ajax_request('%22VelocityVariables%22.velocity', 'velocityField')" value="Send via AJAX">


<!--------------------------------------------------------------------------------------------->
<p>&nbsp;</p>
<table border="1" width="100%" id="table1">
<tr>
<td id="td1" style="width:32px">
0
</td>
<td>
<div style="width:1px; height:16px; border:1px; background-color:#0000FF;" id="bar"></div>
</td>
</tr>
</table>
<p><iframe name="hiddenFrame" height="0" width="0">
Your browser does not support inlineframes or inlineframes are currently not enabled.
</iframe></p>

</body>
</html>
 
Seite 2
Datei ajaxbase.js

// support functions
var g_browser_ie = false;
var g_browser_opera = false;
var g_browser_firefox = false;

function DetermineBrowser() {
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf("msie") >= 0) {
browser = "IE";
g_browser_ie = true;
} else if (userAgent.indexOf("opera") >= 0) {
browser = "Opera";
g_browser_opera = true;
} else if (userAgent.indexOf("firefox") >= 0) {
browser = "FireFox";
g_browser_firefox = true;
}
}

// Create an HTTP Requests Object independent of browser type
// and send the request to the provided URL
function DoHttpRequest(userobj, url, proc, asynch, xml) {
var httpRequest;

httpRequest = GetXMLHttpRequestObj(xml);
if (!httpRequest) {
alert("HttpRequest failed: cannot create");
return false;
}

userobj.userProc = proc; // user defined handler
userobj.httpRequest = httpRequest;
userobj.currUrl = url;
userobj.isXMLRequest = xml;

httpRequest.open('GET', url, asynch); // process the request asynchronously
// HttpRequestHandler max be called now, but not with readyState 4 !
httpRequest.onreadystatechange = function() { HttpRequestHandler(userobj); };
// force requesting from server, otherwise IE may take the response from cache !
httpRequest.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
httpRequest.send(null);
if (g_browser_firefox && !asynch) {
// firefox does not call the handler if synchron !
HttpRequestHandler(userobj);
}
httpRequest = null; // necessary for IE, to break the object cycle imposed by the use of closures,
// which prevents IE's garbage collector from releasing the objects
return true;
}

// Create an HTTP Requests Object independent of browser type
function GetXMLHttpRequestObj(xml) {
var bHttpRequest = false;
var httpRequest = null;

// Test whether the browser provides an XMLHttpRequest Objekt (Mozilla and other)
try {
bHttpRequest = (window.XMLHttpRequest != null);
} catch (e) {
}
if (bHttpRequest) {
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType && xml) {
// The result is to be handled as XML doc
httpRequest.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) {
// use ActiveXObject if Browser is IE
try {
// Microsoft IE >= V5
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
// Microsoft IE >= V6
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
return httpRequest;
}


// Handler for the HTTP request, calls in turn the user defined handler
function HttpRequestHandler(userobj) {
var httpRequest = userobj.httpRequest;
// check if loading response has finished
if (httpRequest && httpRequest.readyState == 4) {
var userProc = userobj.userProc;
userobj.httpRequest = null;
userobj.userProc = null;
if (userProc) {
userProc(userobj, httpRequest.responseText, httpRequest.status);
}
}
}

function send_ajax_request(variable, fieldId)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest(); // Mozilla and others
}
else if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP"); // Microsoft
}
else
{
alert("Der Browser unterstuezt kein Ajax");
}
var value = document.getElementById(fieldId).value;

var req_url = "?"+variable+"="+value+"&"+Math.random();
//debug alert(req_url);
req.open("GET", req_url, false);
req.onreadystatechange = ajax_callback;
req.send(null);
}

function ajax_callback()
{
if (req.readyState == 4)
{
//debug alert(req.responseText);
//debug alert("Schreiben erfolgreich!");
}
}
 
Zurück
Oben