Welcome, Guest
Username: Password: Remember me

TOPIC: TCP Remote connection

TCP Remote connection 13 years 9 months ago #839

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
Hi!

I'm currently working on a project where I need to connect to another PC (windows XP, .net) running the \"engine\" for a factory simulation. The solution that was chosen for the setup was a TCP/IP connection with a server and a client on both sides (proview and .net). The server constantly listens and the client only sends messages.

But as I start to browse the hierarchy of nodes I'm a bit lost. I have look at the UDP example in the designer's guide but it has not enough details and as said TCP/IP is the goal. I only need to seed a sequence of ints (about 3 numbers max) over the network, so nothing fancy really.

As far I have created a RemoteConfig node with two RemoteTCP nodes, one server and one client. They have in turn got a address and and ports and under them I have created a RemoteTrans node each. What nodes do I need to create under them and do I need to create structs for them in the mentioned ra_plc_user.h?

How do I intreact whit the RemoteTransSend/Rcv object in the PLC and get the RemoteTrans object to apper in the PLC Plant view?

Have I got it all wrong? A simple step to step would be golden!

Best Regards!
//Björn
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #841

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3178
  • Thank you received: 502
  • Karma: 133
Hi Bjorn,

Below the RemTrans objects you have to place a buffer object which will contain the message. If you are sending, you fill in the buffer object in the RemTransSend plc window, and if you are receiving you read the buffer object and unpacks the messag in the RemTransRcv plc window.

As your messages only contains integers, you can use a IArray100 as a buffer object. You then don't have to declare a special struct for the message. You declare the Da1 pointer with

[code:1]classdef Da1 IArray100;[/code:1]

in the DataArithm code and use Da1->Value[0], Da1->Value[1] etc to access the message data.

Note also that the message normally contains a header, which can be removed by setting DisableHeader in the RemNode object.

If you don't view the plant in the plc editor, you can select objects in the configurator and connect to function objects in the plc editor.

/Claes
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #843

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
Thanks for the quick response!

What I have done so far is:

*Remote nodes in Nodes-tree in volym:

[code:1]Remote - RemoteConfig
Server - RemnodeTCP
ReceiveData - RemTrans
Data - Buff256
Client - RemnodeTCP
SendData - RemTrans
Data - Buff256[/code:1]

*In both RemnodeTCP I switch to DisableHeader = 1, type in address and ports.
*In the RemTrans I did nothing except changed one to Direction = Send. No StructName or Struct file per your instructions. What about the address attributes?
*Buffers I did nothing with it.

I'm I to do anything with the PlatHeir, add any varibles or such?

I was able to do a GetData object in the PLC and connect the SendData RemTransNode by clicking on it in the Volym-window and then clicking connect in the PLC-window, is that what you ment by \"configurator\"?

The define to a IntArray is to be place in the RemTransRec/Send subwindows?

Thanks for the help!
//Björn
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #844

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3178
  • Thank you received: 502
  • Karma: 133
Hi Bjorn,

My idea was to replace the Buff256 objects with IArray100 objects.

In the RemTrans objects you also have to set DataLength to the size of the message (6 bytes ?). The Address is used to separate different types of messages, and as you only have one message per RemNode you don't need to use this.

The DataArithm code in the RemTransSend subwindow would be something like

[code:1]classdef Da1 IArray100;

Da1->Value[0] = I1;
Da1->Value[1] = I2;
Da1->Value[2] = I3;[/code:1]

and the code in the RemTransRcv would be

[code:1]classdef Da1 IArray100;

OI1 = Da1->Value[0];
OI2 = Da1->Value[1];
OI3 = Da1->Value[2];[/code:1]

/Claes
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #845

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
Thanks, I think that did it.
At least the proview client and windows server have a working connection and the proview server and windows client have established a connection but does not respond to command.

Can't debugg due to another error/problem, see my other thread.
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #853

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
I got the connection up and running but I have now problem whit my receive code:
Main: [code:1]classdef Da1 IArray100;

OI1 = Da1->Value[0];
OI2 = Da1->Value[1];
OI3 = Da1->Value[2];

if(OI1 >= 600){
od6 = 1;
}
else if(OI1 >= 500){
od5 = 1;
}
else if(OI1 >= 400){
od4 = 1;
}
else if(OI1 >= 300){
od3 = 1;
}
else if(OI1 >= 200){
od2 = 1;
}
else if(OI1 >= 100){
od1 = 1;
}
else{//Wrong!
}
[/code:1]
First Receiver: [code:1]
if(d1 == 1){

// Reset
if(l1 == 100){
od1 = 1;
}
// Factory ON
else if(l1 == 101){
od2 = 1;
}
// Factrory OFF
else if(l1 == 102){
od2 = 0;
}
// Total In increase
else if(l1 == 103){
OI1 = I2 + 1;
}
// Total Out increase
else if(l1 == 104){
OI2 = I3 + 1;
}
}[/code:1]

Main gets the data stream and checks it's values and sends it to the appropriate receiver. The receiver then deciphers what to do with it.

I get \"l1 undeclared\" in the first receiver, what's whit that? The connections seem ok.
Also can I declare local variables in the DataArithm (example: int v = l1 -100;) for internal use?
In the helper class for dataArithm it states the Int Output as IO, but doesn't work. OI vworks instead... Typo?

//Björn
The administrator has disabled public write access.
Time to create page: 8.348 seconds