Sign in to follow this  
Gammatech

First steps with client display

Recommended Posts

I have my main document that acquires data from the plant once per second on a serial line. All of the displays that the control room want are available either on the main screen or via pop ups. Other interested people want some parts of the data on their local machines so I have taken my first steps into networking.

On a separate machine, connected in a peer to peer network with the main machine, I have a simplified display of the limited data set. I set up a connection called "Client1" to the named main machine and as soon as the connection was established all of the channels and sequences of the main document were visible on my "client1"connection. The data I initially wanted was all in channels on the main machine and displayed in variable value components on the client screen perfectly. One of my sequences on the main machine is set as auto run and declares and initialises all the variables. On the client machine this sequence is visible under the client1 connection and is marked as auto run but none of the named variables exist. So I now have some questions:

1) I assume I have to declare any variables I want in the local connection of the client machine. If I preface the variable from the main machine with the connection name i.e. Client1.ResponseTime will that hold the current value from the main machine? If not how can I get the value across to the client?

2) If I uncheck the broadcast box on those channels on the main machine that hold data that I don't need on the client presumably they won't then be sent out over the network each second?

3) Some of the channels that I do want need say a history of 600 (10 minutes worth) but other channels need far less probably only the latest value so is there a way to store 600 of some but far less of others? I'm thinking that as the client document will probably be minimised much of the time there seems little point in hogging any more memory than needed.

Sorry if these queries seem mundane but this is my very first attempt at networking!

TIA

Martin

Share this post


Link to post
Share on other sites

1) Variables don't pass across the network. Sequences, although you can see (and at one time at least, edit) them across the net, do not run across the net. So a sequence on your server will not execute on the client, just the server. You need to create a sequence in your "Local" connection to have it run locally on the client. If you need access to data in variables on the server, you'll need to replicate that data into Test channels on the server. Channels are the only way to pass data back and forth.

2) Correct, but only if you connect via the slim stream. Full stream broadcasts everything.

3) 600? I wouldn't worry about it. That's only 9600 bytes of data. You can limit the history on all channels (a setting in the connection window), but you can't limit individual channels.

Share this post


Link to post
Share on other sites

Hi,

What would happen if there were two computers, each running a Run Time version of DAQFactory with my document measuring a different process stream on each. I assume I would have to make the client displays on other machines in the network have two connections one to each monitoring machine and then the client display would have two alternative displays for process stream 1 and 2.

Regards,

Martin

Share this post


Link to post
Share on other sites

Yes, you could have a remote copy connecting to both process streams. You'd create two connectors, one for each. You then have two options: if you only want to view one at a time, or perhaps you have some pages that you want to switch between the two processes, you can simply put channel names without the connector prefix and set the default connector to whichever remote connection you want and the pages will update as soon as you change the default connector (assuming channel names are the same)

If you want to view both data streams on the same page, then you'll need to add the connector name prefix so DAQFactory knows which is which.

You can, of course, use a combination of both techniques.

Share this post


Link to post
Share on other sites

Hi,

That all seems quite clear, thanks.

As far as getting the value stored in variables on the main machine over the network you say put them in a test channel. Would this be done the same as normal update of a channel using AddValue()? If so I assume it could be done each time the value was changed as the client would retrieve the most recent value by setting Client1.Variable = ServerChannel[0]. Does a channel value only get sent when it is updated or is it sent repeatedly? Sorry if this is too basic but a week or so ago I knew absolutely nothing about networking!

Martin

Share this post


Link to post
Share on other sites

Yes, it would be done that way, or you could use a Test D to A channel and just use =:

mychan = value

It gets sent whenever it gets updated (note I didn't say changed, just set, so doing chan = 3 repetitively will actually send the value 3 each time).

Share this post


Link to post
Share on other sites

Hi,

One of the variables I want to get across to the client document is a string so when I made the channel I selected I/O Type - String. Another was an integer that could be in the range -7 through to 7 (its really just an indicator of process type) so I was unsure what I/O type to use for that. DtoA is used in your example, should I use that for all or stick with string for the string variable?

Which is quicker the assignment MyChannel = Variable or MyChannel.AddValue(Variable)

Martin

Share this post


Link to post
Share on other sites

There are only really two data types in DAQFactory, number and string. So integers fall under number. Using D to A is sometimes more convenient, but using AddValue is significantly faster, so I'd use that.

Share this post


Link to post
Share on other sites

Hi,

My main document has a group of channels that are only updated at the end of a shift. The shifts are usually 8 hours but could be 1,2,4,6,8,12 or 24. The group of channels all have history and persistence set to 1000. This allows the local operator to search through the historical shift records. The broadcast to the clients only occurs at the end of the shift as the shift channels are updated so, if the client has only been running for a limited period, there is either little or no shift data available to search locally. Is there a way I can either search (in the Client) through the shift data stored on the server computer or send the stored shift data as the client starts to run?

Martin

Share this post


Link to post
Share on other sites

You can use the GetHistory() function from the remote machine to retrieve older values. It will only pull from what's in memory on the server, not from any logged data. For example:

myConnection.GetHistory("myTag", systime() - 3600, systime())

Share this post


Link to post
Share on other sites

Thanks, I'll try that.

Another thought crossed my mind, If I make the client software have more than one connection (to various process stream monitors in the plant) is there a way to find out from script how many of these connections actually exist or does it have to be set up on site as the systems are configured.

Thanks,

Martin

Share this post


Link to post
Share on other sites

Hi,

I can't find any function GetHistory in the help, has this been added since the help was written?

I assume as the connection name I have used on my fledgling client is "Client1" I would use Client1.GetHistory() Presumably the "MyTag" is the name of the channel on the server computer and is passed in quotes as a string and the second and third arguments give the last hours data. Do these last two arguments have to be time values or could they be 1000 and 0 as I want to retrieve the last 1000 readings.

I found GetHistoryCount as a channel action but Client1.ShiftAshFinal.GetHistoryCount() gives the number of elements that have been sent to and subsequently stored on the client computer rather than the number stored on the main computer.

I have channels set up in the local connection that I want to fill with the data that is stored on the main computer so that, for example, a manager running the client software can look at any one of the last 1000 shift figures without needing to walk to the main machine that actually has the archived data.

TIA

Martin

P.S Out of interest what is the difference between the "Fast Reply" and "Add Reply" buttons on the forum? I tend to use "add reply" rather than "fast reply" and still your valued assistance is astonishingly rapid!

Share this post


Link to post
Share on other sites

GetHistory isn't in the help. It was added for a particular application and never made it into help. You are correct in your assumptions, except that time has to be absolute time. Typically you use GetHistory in an autostart sequence after the remote connection is established.

On your other question, you can dynamically create and remove remote connections.

PS: fast reply and add reply are basically the same. Fast reply displays the editor at the bottom without refreshing the browser, so is, well, faster. However, it doesn't have all the options that Add Reply has. Usually the only time I use Add Reply is when I need to include an attachment. Almost all the time I use fast reply, as I am now.

Share this post


Link to post
Share on other sites

So if my client (a manager looking occasionally at the process stream) wants to pull all of the shift data off the server without knowing exactly how many elements have so far been filled in memory on the sever could I use

myConnection.GetHistory("myTag", 0, systime())

and get how ever many of the 1000 had actually been filled in the server's history? I assume that as GetHistory() needs the index limits to be in absolute time, setting the first to zero and the last to SysTime() must get all the data in the server's history, which in my case would be between 0 and 1000 elements.

Is there any way to get at the persistence data from the server?

TIA

Martin

Share this post


Link to post
Share on other sites

Presumably. I don't use getHistory much so frankly have forgotten. I'd just give it a try. As for persist data, again I do not remember if it pulls from persist, but why not just increase your History? 1000 is a really small number. 1000 data points only take up 16K of memory, which is nothing nowadays.

Share this post


Link to post
Share on other sites

In an earlier reply you said:

"Typically you use GetHistory in an autostart sequence after the remote connection is established."

How do I know when the remote connection is established? I look for one of the channels that comes over every second from the server computer and when it is not empty I conclude that the connection is established. Is this ok?

If(IsEmpty(Client1.TPH[0]))
   While((Count < 30) && (IsEmpty(Client1.TPH[0])))
	  Delay(1)
	  Count ++
   EndWhile
EndIf
// Either data from stream 1 has been found or counter timed out
If(!IsEmpty(Client1.TPH[0]))
   Client1.GetHistory("ShiftMoistFinal",0,Systime())
   Client1.GetHistory("ShiftEndFinal",0,Systime())
   Client1.GetHistory("ShiftCVFinal",0,Systime())
   Client1.GetHistory("ShiftNumberFinal",0,Systime())
   Client1.GetHistory("ShiftStartFinal",0,Systime())
   Client1.GetHistory("ShiftTonnesFinal",0,Systime())
EndIf

I wait for up to 30 seconds for some data to come in and thus show the connection is established. When the While loop terminates there is either a valid connection or 30 seconds has elapsed. If there is a connection then I get the historical data that I want. How long should I wait for a connection to establish? 30 seconds is a long while if I'm going to check a number of possible streams.

Can you suggest a better way of proving the connection and then getting the historical data across?

TIA

Martin

Share this post


Link to post
Share on other sites

That is about right, though I don't know why you would have it timeout. I'd just loop continuously, probably with a shorter delay, and set the priority of the sequence to 0.

Share this post


Link to post
Share on other sites

I put in the timeout for the condition that a stream is not present. If I loop continuously without a timeout won't the system hang?

If I do need a timeout what would you recommend and how low would you suggest the delay can be?

Thanks

Share this post


Link to post
Share on other sites

By timeout I mean that you only loop 30 times. You do need the delay, though it could be much smaller, especially if your sequence priority is low. 0.1 would be a good value.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this