question

Tuan avatar image
0 Likes"
Tuan asked Tuan commented

How to send the information in the Global table to socket client?

The file is socket server

How to send the information in the global table to socket client?

擷取1.png

Send information through the circle on the image below

How to modify so as to sent table values to socket client?

擷取.png

GUI_Socket_InterArrivalTime.fsm

FlexSim 20.0.10
global tablesocket
擷取1.png (3.7 KiB)
擷取.png (7.4 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered Tuan commented

You can use the string.fromNum() method along with the Table("TableName")[row][col] format to compose the message being sent with serversend().

But how do you want to send values from the table to the client? You could send the value from the last row every time a row is added (in the same event/code that is adding the rows), like this:

serversend(server,string.fromNum(Table("entry sink time")[Table("entry sink time").numRows][1]));

Or you could send the entire table of numbers in one big "blob" after the model has finished running, like this:

string message = "";
Table table = Table("entry sink time");
int tableNumRows = table.numRows;

for (int row = 1; row <= tableNumRows-1; row++) {
   message += string.fromNum(table[row][1]) + ", ";
}
message += string.fromNum(table[tableNumRows][1]);

serversend(server, message);

But you most likely want to use some combination of string.fromNum() and Table()[row][col].

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Tuan avatar image Tuan commented ·

Thank you this is very helpful!!

0 Likes 0 ·