Process interfacing via an automation system (PLC, PC)
10.8 Remote client
SIMATIC MV420 / SIMATIC MV440
Operating Instructions, 04/2013, A5E02371045-06
329
Pseudocode example
C# Pseudocode XML Restore
Stream
newStream;
string
xmlDoc =
File
.ReadAllText(
"C:\\mv400para.xml"
);
ASCIIEncoding
encoding =
new
ASCIIEncoding
();
// Prepare POST data
string
postData =
"[REMOTEXMLUPLOADPARA]\r\nContent-Disposition: form-data; name=\"xmlfile\"\r\nContent-Type: text/xml\r\n\r\n"
+
"\r\n"
+
// remove next line if TCP settings shall not be imported
"[REMOTEXMLUPLOADPARA]\r\nContent-Disposition: form-data; name=\"importtcp\"\r\n\r\non\r\n"
+
// remove next line if PROFINET settings shall not be imported
"[REMOTEXMLUPLOADPARA]\r\nContent-Disposition: form-data; name=\"importdp\"\r\n\r\non\r\n"
+
// remote next line if security settings shall not be imported
"[REMOTEXMLUPLOADPARA]\r\nContent-Disposition: form-data; name=\"importsec\"\r\n\r\non\r\n"
+
// remote next line if codes shall not be imported
"[REMOTEXMLUPLOADPARA]\r\nContent-Disposition: form-data; name=\"importcodes\"\r\n\r\non\r\n"
+
"[REMOTEXMLUPLOADPARA]\r\n"
;
buffer = encoding.GetBytes(postData);
// Create http request
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(
"http://192.168.0.42/xml/restore.cgi"
);
myRequest.Method =
"POST"
;
myRequest.ContentType =
"multipart/form-data; boundary=[REMOTEXMLUPLOADPARA]\r\n"
;
myRequest.ContentLength = buffer.Length;
// Send the data.
newStream = myRequest.GetRequestStream();
newStream.Write(buffer, 0, buffer.Length);
try
{
// Get response
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myRequest.GetResponse();
// Get response data
int
response = myHttpWebResponse.GetResponseStream().ReadByte();
if
(response != -1)
{
Char
value = (
Char
)response;
if
(value.Equals(
'1'
))
Console
.WriteLine(
"XML restore succeeded, device is restarting..."
);
else if
(value.Equals(
'2'
))
Console
.WriteLine(
"XML restore succeeded only partially, not all codes could be imported.
Device is restarting. More information via graphical user interface."
);
else
Console
.WriteLine(
"XML restore failed. More information via graphical user interface."
);
}
}
catch
(System.Net.WebException we)
{
Console
.WriteLine(
"NO PERMISSION FOR XML RESTORE!"
);
}
Summary of Contents for SIMATIC MV420
Page 2: ......
Page 418: ...Glossary SIMATIC MV420 SIMATIC MV440 416 Operating Instructions 04 2013 A5E02371045 06 ...
Page 423: ......