# Design of a Generic Wearable-Robot Monitoring System (GWRMS) for Patients with Lower Limb Paralysis
## 3 Materials and Methods
### Wearable Robot
To optimise the efficiency of the GWRMS, the communication module of the wearable robot's software uses a TCP socket to monitor data on demand instead of conducting ongoing monitoring. As shown in Table 3, this method improves the performance of wearable robots' embedded processors. When monitoring proceeds through TCP socket communication, the communication module collects data from each module, packs it as JSON string data, and sends it as a response to a TCP/IP request. The GWRMS utilises the functions of the following GNU software [13]: mpstat, ps, free. The daemon software on the wearable robot of the GWRMS was implemented with Lua, and TCP socket communication was implemented with LuaSocket. Part of the pseudo code for the communication module is shown Algorithm 1. ```
set tcp socket with ip and port while true do  init client = accepted tcp session  client timeout = 0  init partial = client data  if partial is valid then  init processes = {}  init process = result of shell execution result \"ps -a -o comm,pid,%cpu,sz | awk {'print $1\(\surd\)\"$2\(\surd\)\"$3\(\surd\)\"$4\(\surd\)\"  init tbl = split table of processes by new line character for i = 2 to size of tbl do  init data = split table of i th element of tbl by comma character  push table to processes by [name=data[1], pid=data[2], cpu=data[3], mem=data[4]] endfor init data = json encoded string by process  init data = {}  init dataSize = 8000 while true do  init doNext = data:len() > index  init targetIndex = minimum value between index and length of data  push string to datas by subbed string between targetIndex-(dataSize-1) and targetIndex  increment index by dataSize if doNext not equal true then  break the loop  endif endwhile
```  
**Algorithm 1** Pseudo code for the communication module of the GWRMS daemon software. \begin{table}
\begin{tabular}{c c} \hline \hline
**On-Demand Monitoring** & **Ongoing Monitoring** \\ \hline Idle when monitoring is not needed & Maintains continuous monitoring \\ \hline Uses resources only when needed & Always uses system resources \\ \hline Monitoring is invoked only by TCP request & Maintains monitoring without requests \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison between on-demand and ongoing monitoring. send data length to client  
close client session  
for i = 1 to length of data do  
set client = accepted tcp session  
client timeout = 0  
set partial = client data  
if partial not equal nil then  
send i th string of data to client  
close client  
endif  
endfor  
endif  
endwhile  
The pseudo code creates a TCP socket session and receives the session corresponding to the request when executing the request from the TCP socket. Then, after executing and collecting the command specified in the shell, a new session is created. The length of the message that can be sent in one session is limited, so the message length is first sent to the server. The entire message is then sent and the session ended. The server then receives the message until the message length specified at the creation of the session is satisfied.