I'm trying to process the returndata from this device: http://www.controlbyweb.com/support/five-input.html
My code is thus: - Public Class ControlByWebTester_Form
-
Private Sub Read_DAQ()
-
Dim tcpClient As New System.Net.Sockets.TcpClient()
-
Dim port As Integer
-
Dim ipAddr As String = Convert.ToString(IPAddr_TextBox.Text)
-
-
Try
-
'Connect to DAQ
-
port = Convert.ToInt32(IPPort_TextBox.Text)
-
tcpClient.Connect(IPAddr_TextBox.Text.ToString(), port)
-
-
If tcpClient.Connected Then
-
-
Me.Pwr_Picturebox.Image = My.Resources.Red_LED___On
-
-
'Create a network stream object
-
Dim netStream As NetworkStream = tcpClient.GetStream()
-
-
'If we can read and write to the stream then do so
-
If netStream.CanWrite And netStream.CanRead Then
-
-
'Send the on command to read status of DAQ
-
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("GET /state.xml?noReply=0 HTTP/1.1" & vbCrLf & vbCrLf)
-
netStream.Write(sendBytes, 0, sendBytes.Length)
-
-
'Get the response from DAQ
-
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
-
netStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
-
-
'Parse the response and update the webrelay state and input text boxes
-
Dim returndata As String = Encoding.ASCII.GetString(bytes)
-
-
'Parse out the DAQ state
-
Dim array1 As Char() = returndata.ToCharArray()
-
-
Whereas "array1" contains the string returned from the device. However, that string actually contains an XML response, and try as I might, I can't seem to find how to process it AS XML. The following is exactly the data being sent from the device:
-
"<?xml version="1.0" encoding="utf-8"?>
-
<datavalues>
-
<input1state>0</input1state>
-
<input2state>0</input2state>
-
<input3state>0</input3state>
-
<input4state>0</input4state>
-
<input5state>0</input5state>
-
<count1>0</count1>
-
<count2>0</count2>
-
<count3>0</count3>
-
<count4>0</count4>
-
<count5>0</count5>
-
<powerupflag>1</powerupflag>
-
</datavalues>"
-
-
For now, I'm processing the string as follows:
-
Dim PictureBoxList() As PictureBox = {In1_Picturebox, In2_Picturebox, In3_Picturebox, In4_Picturebox, In5_Picturebox}
-
Dim k As Int16 = 67
-
For i = 0 To PictureBoxList.Length - 1
-
If array1(k) = "1" Then
-
PictureBoxList(i).Image = My.Resources.Green_LED___On
-
Else
-
PictureBoxList(i).Image = My.Resources.Green_LED___Off
-
End If
-
k = k + 30
-
Next
k is where each of the values reside within the string.
Problem: How do I process it as actual XML Data, and use that to change the state of my pictureboxes?
4 2400
Code tags weren't available for my first post. Sorry.
Thanks Isaac. I ended up going about it the 'semi-hard way' on this particular program. For now, this works, but I would LOVE to pick your brain about other aspects of both the DAQ and the Quad-Relay. Is there any way we can get together to discuss? -
-
'Parse out the DAQ state
-
Dim array1 As Char() = returndata.ToCharArray()
-
Dim source As Char() = array1
-
Dim TextBoxString As String = ""
-
Dim DAQDoc As New XmlDocument
-
Dim DAQNodes As XmlNodeList
-
Dim DAQNode As XmlNode
-
DAQDoc.LoadXml(source)
-
DAQNodes = DAQDoc.GetElementsByTagName("datavalues")
-
Dim in1variable As String = ""
-
Dim in2variable As String = ""
-
Dim in3variable As String = ""
-
Dim in4variable As String = ""
-
Dim in5variable As String = ""
-
Dim in1value As String = ""
-
Dim in2value As String = ""
-
Dim in3value As String = ""
-
Dim in4value As String = ""
-
Dim in5value As String = ""
-
Dim inVarArray() As String = {in1variable, in2variable, in3variable, in4variable, in5variable}
-
Dim inValArray() As String = {in1value, in2value, in3value, in4value, in5value}
-
Dim m As Integer = 0
-
For Each DAQNode In DAQNodes
-
Dim baseDAQNodes As XmlNodeList
-
Dim bFirstInRow As Boolean
-
baseDAQNodes = DAQNode.ChildNodes
-
bFirstInRow = True
-
'Load the varible names and values
-
For Each baseDAQNode As XmlNode In baseDAQNodes
-
TextBoxString = TextBoxString + (baseDAQNode.Name & ": " & baseDAQNode.InnerText) + vbCr & vbLf
-
inVarArray(m) = baseDAQNode.Name
-
inValArray(m) = baseDAQNode.InnerText
-
m = m + 1
-
If m = 5 Then
-
Exit For
-
End If
-
Next
-
Next
That's great to hear that you got it working. Definitely feel free to contact our support team by phone (1-435-590-5999) or email (support@Contro lByWeb.com) to help you out with some more specific questions about any of our products.
Also, on our website you can download any of the product manuals to help in answering any questions you might have. The manual for the WebRelay-Quad is located here: www.controlbywe b.com/webrelay-quad/downloads.html
Looking forward to hearing from you.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Neil West |
last post by:
I’m trying to drag & drop listview items between two instances of my app. The
actual data that’s passed in DoDragDrop is an arraylist that’s been
serialized to a memorystream. The contents of the arraylist are objects of a
simple, serializable custom class that allows the recipient listview to
reconstruct the dragged listitems. (the contents of the arraylist actually
don’t matter…they can be simple integers and the issues in...
|
by: kevinSTS |
last post by:
Hi.
I'm trying to run an update query in ACC97 to update a data string where only part of the data needs to be changed. Since I don't do this often, I cant for the life of me remember how to do it.
Here'w what the data looks like: 10-1100-120-000-10-10-00-000
I need to change only this portion: 10-1100-120-000-10-10-00-000
Any ideas on how to do this in a query?
Thanks.
Kevin
|
by: caine |
last post by:
I want to extract web data from a news feed page
http://everling.nierchi.net/mmubulletins.php.
Just want to extract necessary info between open n closing tags of
<title>, <categoryand <link>. Whenever I initiated the extraction,
first news title is always "MMU Bulletin Board RSS Feed" with the
proper bulletin's link stored, but not the correct news title being
stored.
Necessary info only appears within <itemand </itemwhich consists...
|
by: mix01 |
last post by:
Hi,
I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help.
Many thanks,
Mix01
Version of the program
|
by: maverickx |
last post by:
Hi everyone,
this is about my one project, i was planning to do like this: Firstly i printed out the source code of one html page on the DOS window, and then use PERL Regular Expression to extract specifc data from the source code , at last save these data in MYSQL tables. Does this work?
| |
by: Tequilaman |
last post by:
Hi everybody!
I want to search some data string of 3 to 11 characters within a hich number of files. tese files are text files with names that are not .txt but .10F etc. All are in one ffolder, but the number of files is too high to open them all.
This should not be done from a server, but from an normal maschine searchin on a network drive.
The number of files varies every day and I must rerun this search a few times within the next...
|
by: cillian |
last post by:
Hi
would appreciate any help with this
Working on a table in which a string value is stored
tableA.somestring = a, b, c, d, e, f, g , i,
The string only ever contains these 8 comma separated values
I am looking for a way to process the string as follows and output a decimal 8,2
|
by: rajesh0303 |
last post by:
I want to extract substring from string and replace them by character.
.ex:In "lphrd" , I want to extract and ,and want them to replace be replaced by Ä and É. so, that the result string is ÄlprÉd.
Need help...
|
by: code green |
last post by:
I have a text field called notes in which users have typed almost anything they like.
I need to find numeric data randomly inserted in there.
So for example there may be a telephone number and an account number
in amongst varied text.
How do I extract this data in a SELECT query in the format
id number
xx 0107364561 2124
OR
|
by: Michael Fuller |
last post by:
We are currently searching for a solution to manage data. We have a bunch of laboratory and field analytical data in an Access 2003 database. We also have some plant process data that is recorded in a Wonderware Historian data server, which I think is based upon MS SQL Server.
We often have need to look at some of the data from each database together, but querying and managing the 2 seperate databases is somewhat costly and prone to poor...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |