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 // Sends the writes and sends the request when the connecting is established
this.socket.once('connect', () => { this.socket.once('connect', () => {
try { 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); this.request.sende(this.socket);
} catch (error) { } catch (error) {
response = stringifyError(error as Error); response = stringifyError(error as Error);

View File

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