'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim STATE As Map
Dim HC As HttpClient
Dim PARSER As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim URL As String
URL = "http://192.168.0.2/cgi-bin/ILRReadValues.exe"
Dim Title, Link, Description, pubDate As String
' txt result LIST
Dim TxtList As List
' Dim SRLview As ScrollView
Dim ColDrw As ColorDrawable
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
PARSER.Initialize
End If
' Activity.LoadLayout("2")
HC.Initialize("HC")
End Sub
Sub Activity_Resume
Dim req As HttpRequest
TxtList.Initialize
req.InitializeGet(URL)
HC.Execute(req, 1)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error connecting: " & Reason & " " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
' Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirInternalCache, "Rss.txt", False), True, TaskId)
Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirDefaultExternal , "Rss.txt", False), True, TaskId)
End Sub
Sub XMLResponse_StreamFinish (Success As Boolean, TaskId As Int)
Dim In As InputStream
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
' parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "Rss.txt")
PARSER.Parse(In, "Parser")
In.Close
' TEST TEST TEST TEST TEST TEST TEST TEST
File.WriteList(File.DirDefaultExternal, "List.txt", TxtList)
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
If PARSER.Parents.IndexOf("channel") > -1 Then
If Name = "title" Then
Title = Text.ToString
Else If Name = "link" Then
Link = Text.ToString
Else If Name = "description" Then
Description = Text.ToString
Else If Name = "pubDate" Then
pubDate = Text.ToString
End If
End If
If Name = "item" Then
' EditText1.Text = EditText1.Text & Title & CRLF & Link &CRLF& Description & CRLF _
' & pubDate & CRLF & CRLF
TxtList.add(Title)
TxtList.add(Link)
TxtList.add(Description)
TxtList.add(pubDate)
End If
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://192.168.216.22/dbtest/get.php", Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub
<?xml version="1.0" encoding="UTF-8"?>
<body>
<version>1.0</version>
<client>IMasterPhoenix5_14_05</client>
<client_ver>5.14.0501</client_ver>
<item_list_size>2</item_list_size>
<item_list>
<i><n>@GV.PLCMODE_ON</n></i>
<i><n>@GV.ONBOARD_INPUT_BIT1</n></i>
</item_list>
</body>
Sub Activity_Create(FirstTime As Boolean)
Dim job2 As HttpJob
Dim su As StringUtils
Dim CSV As List
Dim Headers As List
Dim InsertBefore As Int
Dim NewString(5) As String
Dim Table As List
Activity.LoadLayout("layout1")
'Table = su.LoadCSV2(File.DirAssets, "pdd.csv", ",", Headers)
Table = File.ReadList(File.DirAssets, "pdd.csv")
For i = 0 To Table.Size-1
Log(Table.Get(i))
Next
'Send a POST request
job2.Initialize("Job2", Me)
job2.PostString("http://192.168.3.150/cgi-bin/ILRReadValues.exe", "<body><version>1.0</version><client>IMasterPhoenix5_14_05</client><client_ver>5.14.0501</client_ver><item_list_size>2</item_list_size><item_list><i><n>@GV.PLCMODE_ON</n></i><i><n>Main.Test1</n></i></item_list></body>")
'$aValues = _StringBetween($sXMLResponse, "</n><v>", "</v></i>")
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job2"
'print the result to the logs
Log(Job.GetString)
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim su As StringUtils
Dim Table As List
'Datei, die ausgewertet werden soll
'Name,Data Type -> Header
'@GV.Input_Analog,WORD
'@GV.Output_Analog,WORD
'@GV.TestOutputs,BOOL
'@GV.PLCMODE_ON,BOOL
'@GV.ONBOARD_INPUT_BIT1,BOOL
'@GV.Test_BOOL,BOOL
'Main.Q_Bool,BOOL
'Main.V001,BOOL
'Main.Test1,BOOL
'Main.V005,REAL
'Main.V004,String(80)
Table.Initialize
Table = su.LoadCSV(File.DirAssets, "pdd.csv", ",")
Log (Table.Size)
Dim sColumn() As String 'Added for debugging
Dim i As Int
For i = 1 To (Table.Size)
sColumn = Table.Get(i)
Log(sColumn(0)) '=Name
Log(sColumn(1)) '=Data Type
Next
End Sub
Dim su As StringUtils
Dim CSV As List
Dim i, j, ColCount, RowCount As Int
Dim Table As List
Table = su.LoadCSV(File.DirAssets, "pdd.csv", ",")
RowCount=Table.Size
ColCount=2
Dim MyArray(RowCount, ColCount), aRow() As String
For i=0 To RowCount-1
aRow=Table.Get(i)
For j=0 To ColCount-1
MyArray(i, j)=aRow(j)
Next
Log(MyArray(i, 0))
Next
Log(MyArray(6, 0))
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim HC As HttpClient
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
HC.Initialize("HC")
End If
End Sub
Sub Activity_Resume
Dim Query As String
Query = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" & _
"<body><version>1.0</version><client>IMasterPhoenix5_14_05" & _
"</client><client_ver>5.14.0501</client_ver><item_list_size>" & _
"2</item_list_size><item_list><i><n>@GV.PLCMODE_ON</n></i><i><n>@GV.ONBOARD_INPUT_BIT1" & _
"</n></i></item_list></body>"
Send2SPS(Query,1)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub HC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int )
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub
Sub Send2SPS(Query As String, TaskId As Int)
Dim Req As HttpRequest
ProgressDialogShow("connecting...")
Req.InitializePost2("http://192.168.216.22/spstest/track.xml", Query.GetBytes("UTF8"))
HC.Execute(Req,TaskId)
ProgressDialogHide
End Sub
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim Res As String
Res = Response.GetString("UTF8")
Log("Response from server: " & Res)
Select TaskId
Case 1
Msgbox(Res,"Result") ' fail = -1
End Select
Response.Release
End Sub
'Activity module
Sub Process_Globals
Dim HC As HttpClient
End Sub
Sub Globals
Dim Spinner1 As Spinner
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim job2 As HttpJob
Dim su As StringUtils
Dim i, j, ColCount, RowCount, AnzV As Int
Dim Table, CSV As List
Dim XMLString As String
Dim sb, sbXML As StringBuilder
'Laden von layout1
Activity.LoadLayout("layout1")
'Variablennamen und Datentyoen aus pdd.csv auslesen und in MyArray schreiben
Table = su.LoadCSV(File.DirAssets, "pdd.csv", ",")
RowCount=Table.Size
'Anzahl der Variablen -> item_list_size
AnzV = RowCount-1
ColCount=2
Dim MyArray(RowCount, ColCount), aRow() As String
For i=0 To RowCount-1
aRow=Table.Get(i)
For j=0 To ColCount-1
MyArray(i, j)=aRow(j)
Next
Next
'Zusammensetzen des xml-Strings für den HTTP Request
sb.Initialize
For i = 1 To RowCount-1
sb.Append("<i><n>").Append(MyArray(i, 0)).Append("</n></i>")
Next
sbXML.Initialize
sbXML.Append("<body><version>1.0</version><client>IMasterPhoenix5_14_05</client><client_ver>5.14.0501</client_ver><item_list_size>").Append(AnzV).Append("</item_list_size><item_list>").Append(sb).Append("</item_list></body>")
Log("Der Request-String lautet folgend:")
Log(sbXML)
'Send a POST request
job2.Initialize("Job2", Me)
job2.PostString("http://192.168.3.150/cgi-bin/ILRReadValues.exe", sbXML)
'$aValues = _StringBetween($sXMLResponse, "</n><v>", "</v></i>")
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
'print the result to the logs
Log(Job.GetString)
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Was ergibt das Ganze eigentlich ? Ein Cockpit oder Fernsteuerung ?
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim HC As HttpClient
Dim TxtList As List
Dim PARSER As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
HC.Initialize("HC")
End If
PARSER.Initialize
End Sub
Sub Activity_Resume
Dim Query As String
TxtList.Initialize
Query = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" & _
"<body><version>1.0</version><client>IMasterPhoenix5_14_05" & _
"</client><client_ver>5.14.0501</client_ver><item_list_size>" & _
"2</item_list_size><item_list><i><n>@GV.PLCMODE_ON</n></i><i><n>@GV.ONBOARD_INPUT_BIT1" & _
"</n></i></item_list></body>"
Send2SPS(Query,1)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub HC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int )
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub
Sub Send2SPS(Query As String, TaskId As Int)
Dim Req As HttpRequest
ProgressDialogShow("connecting...")
Req.InitializePost2("http://192.168.216.22/spstest/track.xml", Query.GetBytes("UTF8"))
HC.Execute(Req,TaskId)
ProgressDialogHide
End Sub
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim Res As String
Dim In As InputStream
' Res = Response.GetString("UTF8")
Log("Response from server: " & Res)
Select TaskId
Case 1
' Msgbox(Res,"Result") ' fail = -1
' Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirInternalCache, "Rss.txt", False), True, TaskId)
Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirDefaultExternal , "sps.xml", False), True, TaskId)
End Select
End Sub
Sub XMLResponse_StreamFinish (Success As Boolean, TaskId As Int)
Dim In As InputStream
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
' parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "sps.xml")
PARSER.Parse(In, "Parser")
In.Close
' TEST TEST TEST TEST TEST TEST TEST TEST
File.WriteList(File.DirDefaultExternal, "result.txt", TxtList)
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
If PARSER.Parents.IndexOf("body") > -1 Then
If Name = "item_list_size" Then
TxtList.add(Text.ToString)
End If
End If
If PARSER.Parents.IndexOf("item_list") > -1 Then
If Name = "n" Then
'Items = Text.ToString
TxtList.add(Text.ToString)
End If
End If
End Sub
Query = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" & _
"<body><version>1.0</version><client>IMasterPhoenix5_14_05" & _
"</client><client_ver>5.14.0501</client_ver><item_list_size>" & _
"[B][U][I]2[/I][/U][/B]</item_list_size><item_list><i><n>@GV.PLCMODE_ON</n></i><i><n>@GV.ONBOARD_INPUT_BIT1" & _
"</n></i></item_list></body>"
<i><n>@GV.PLCMODE_ON</n></i><i><n>@GV.ONBOARD_INPUT_BIT1"</n></i>
<body>
<version>1.0</version><client>IMasterPhoenix5_14_05</client><client_ver>5.14.0501</client_ver>
<item_list_size>2</item_list_size>
<item_list>
<i><n>@GV.GV.PLCMODE_ON</n><v>1</v></i>
<i><n>@GV.ONBOARD_INPUT_BIT1</n><v>0</v></i>
</item_list>
</body>
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim HC As HttpClient
Dim PARSER As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim TxtList As List
Dim SPSDataTypes As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
HC.Initialize("HC")
PARSER.Initialize
End If
End Sub
Sub Activity_Resume
Dim Query As String
TxtList.Initialize
SPSDataTypes.Initialize
' ** Initialisiere Vars
Load_Defaults
Query = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" & _
"<i><n>@GV.PLCMODE_ON</n></i><i><n>@GV.ONBOARD_INPUT_BIT1</n></i>"
Send2SPS(Query,1)
End Sub
Sub Load_Defaults
SPSDataTypes = File.ReadMap (File.DirDefaultExternal,"SPS_Vars.csv")
' Format eg. ONBOARD_INPUT:WORD
'**Manuelles Laden der MAP
'SPSDataTypes.Put("ONBOARD_INPUT","WORD")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub HC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int )
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub
Sub Send2SPS(Query As String, TaskId As Int)
Dim Req As HttpRequest
ProgressDialogShow("connecting...")
Req.InitializePost2("http://192.168.216.22/spstest/track.xml", Query.GetBytes("UTF8"))
HC.Execute(Req,TaskId)
ProgressDialogHide
End Sub
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim Res As String
Dim In As InputStream
' Res = Response.GetString("UTF8")
Log("Response from server: " & Res)
Select TaskId
Case 1
' Msgbox(Res,"Result") ' fail = -1
' Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirInternalCache, "Rss.txt", False), True, TaskId)
Response.GetAsynchronously("XMLResponse", File.OpenOutput(File.DirDefaultExternal , "sps.xml", False), True, TaskId)
End Select
End Sub
Sub XMLResponse_StreamFinish (Success As Boolean, TaskId As Int)
Dim In As InputStream
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
' parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "sps.xml")
PARSER.Parse(In, "Parser")
In.Close
' TEST TEST TEST TEST TEST TEST TEST TEST
File.WriteList(File.DirDefaultExternal, "result.txt", TxtList)
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
'*** Hole die Anzahl der Werte
If PARSER.Parents.IndexOf("body") > -1 Then
If Name = "item_list_size" Then
TxtList.add(Text.ToString)
End If
End If
' If PARSER.Parents.IndexOf("item_list") > -1 Then
' If Name = "b" Then
' TxtList.add(Text.ToString)
' End If
' End If
' *** Abschnitt item_list
' *** wenn das übergeordnete Element item_list ist
If PARSER.Parents.IndexOf("item_list") > -1 Then
' *** wenn das übergeordnete Element n ist
If PARSER.Parents.IndexOf("n") > -1 Then
' *** wenn das aktuelle Element b ist
If Name = "b" Then
TxtList.add(Text.ToString)
End If
End If
' *** wenn das übergeordnete Element v ist
If PARSER.Parents.IndexOf("v") > -1 Then
' *** wenn das aktuelle Element i ist
If Name = "i" Then
TxtList.add(Text.ToString)
End If
End If
End If
End Sub
Sub TrimSpaces(s As String) As String
s = RTrimSpaces(s)
s = LTrimSpaces(s)
Return s
End Sub
Sub RTrimSpaces(s As String) As String
Dim i As Int
For i = s.Length - 1 To 0 Step -1
If s.CharAt(i) <> " " Then Exit
Next'i
Return s.SubString2(0, i + 1)
End Sub
Sub LTrimSpaces(s As String) As String
Dim i As Int
For i = 0 To s.Length - 1
If s.CharAt(i) <> " " Then Exit
Next'i
Return s.SubString( i )
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?