Optimierung des pdr2 request flows

This commit is contained in:
nwaschk 2025-06-23 18:46:31 +02:00
parent 8feb2f9e13
commit fe1c320081
2 changed files with 22 additions and 14 deletions

View File

@ -54,7 +54,11 @@ export class ProdressConnection {
// Sends the writes and sends the request when the connecting is established
this.socket.once('connect', () => {
try {
this.request.writeEntries(this.requestBody);
// sets the flag for awaiting a response to true
this.request.writeEntry(['integer', 1]);
// writes the body in to the request
this.request.writeBody(this.requestBody);
// sends the request
this.request.sende(this.socket);
} catch (error) {
response = stringifyError(error as Error);

View File

@ -26,23 +26,27 @@ export class ProdressRequest extends Request {
}
/**
* writes entries based on the provided requestTupelList into the request
* writes the provided body into the request
* @param requestBody
*/
public writeEntries(requestBody: Pdr2_RequestBody): void {
// write additionalInformation
for (const tupel of requestBody.additionalInformation) {
this.writeEntry(tupel);
}
// write amount of argument entries
public writeBody(requestBody: Pdr2_RequestBody): void {
// writes additional information into the request
this.writeEntries(requestBody.additionalInformation);
// writes the amount of upcoming entries into the request
this.writeEntry(['integer', requestBody.arguments.length]);
// write arguments
// writes the data entries into the request
for (const args of requestBody.arguments) {
for (const tupel of args) {
this.writeEntry(tupel);
}
this.writeEntries(args);
}
}
/**
* writes entries based on the provided requestTupelList into the request
* @param requestTupelList
*/
public writeEntries(requestTupelList: Pdr2_RequestTupel[]): void {
for (const tupel of requestTupelList) {
this.writeEntry(tupel);
}
}