@tsplc/compiler 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/codesys.js CHANGED
@@ -1704,7 +1704,8 @@ var nativeHttp = ({
1704
1704
  trace
1705
1705
  }) => {
1706
1706
  const requestHeader = trace ? `AppendWire(UDINT_TO_STRING(${trace.job}));AppendWire(':');AppendWire(UDINT_TO_STRING(${trace.sequence}));AppendWire('$R$NContent-Length: ');` : "";
1707
- return {
1707
+ const release = "resolver(xExecute:=FALSE,itfIPAddress:=remoteIP);client(xEnable:=FALSE);writer(xExecute:=FALSE);reader(xEnable:=FALSE);timeout(IN:=FALSE);";
1708
+ const block = {
1708
1709
  id,
1709
1710
  kind: "functionBlock",
1710
1711
  name,
@@ -1742,7 +1743,7 @@ VAR
1742
1743
  END_VAR
1743
1744
  `,
1744
1745
  implementation: `IF NOT ${port("start")} OR ${port("cancel")} THEN
1745
- resolver(xExecute:=FALSE,itfIPAddress:=remoteIP);client(xEnable:=FALSE); writer(xExecute:=FALSE); reader(xEnable:=FALSE); timeout(IN:=FALSE);
1746
+ ${release}
1746
1747
  stage:=0; ${port("busy")}:=FALSE; ${port("done")}:=FALSE; ${port("error")}:=0;
1747
1748
  RETURN;
1748
1749
  END_IF;
@@ -1809,11 +1810,25 @@ IF stage=3 THEN
1809
1810
  END_IF;
1810
1811
  END_IF;
1811
1812
  IF stage=90 THEN
1812
- resolver(xExecute:=FALSE,itfIPAddress:=remoteIP);client(xEnable:=FALSE);writer(xExecute:=FALSE);reader(xEnable:=FALSE);timeout(IN:=FALSE);
1813
+ ${release}
1813
1814
  ${port("busy")}:=FALSE;${port("done")}:=TRUE;
1814
1815
  END_IF;
1815
1816
  `
1816
1817
  };
1818
+ const exit = {
1819
+ id: `${id}:FB_exit`,
1820
+ parent: id,
1821
+ kind: "method",
1822
+ name: "FB_exit",
1823
+ declaration: `METHOD PUBLIC FB_exit : BOOL
1824
+ VAR_INPUT
1825
+ bInCopyCode : BOOL;
1826
+ END_VAR`,
1827
+ implementation: `IF stage>0 AND stage<90 THEN ${port("error")}:=${jobError.network};stage:=90;END_IF;
1828
+ ${release}
1829
+ FB_exit:=TRUE;`
1830
+ };
1831
+ return [block, exit];
1817
1832
  };
1818
1833
  var httpCertificateVerifier = (owner, name, endpoint) => {
1819
1834
  if (!endpoint.tls) {
@@ -1985,8 +2000,8 @@ END_VAR`
1985
2000
  const name = required2(symbols.blockNames.get(fn.id));
1986
2001
  const codecs = serviceCodecs(fn, required2(symbols.blockFields.get(fn.id)), symbols.typeMap, symbols.targetTypes);
1987
2002
  const requestFields = instrumentation.fields.get(fn.id);
1988
- const generated = rpcGlobal ? opcuaServiceBlock(fn, name, codecs, endpoint, rpcGlobal) : httpServiceBlock(fn, name, codecs, endpoint, `${required2(networkName)}.network`, requestFields?.job && requestFields.sequence ? { job: requestFields.job, sequence: requestFields.sequence } : undefined);
1989
- objects.push(generated, ...httpMethods(generated.id, endpoint.transport), ...httpCertificateVerifier(generated.id, generated.name, endpoint));
2003
+ const [generated, ...lifecycle] = rpcGlobal ? [opcuaServiceBlock(fn, name, codecs, endpoint, rpcGlobal)] : httpServiceBlock(fn, name, codecs, endpoint, `${required2(networkName)}.network`, requestFields?.job && requestFields.sequence ? { job: requestFields.job, sequence: requestFields.sequence } : undefined);
2004
+ objects.push(generated, ...lifecycle, ...httpMethods(generated.id, endpoint.transport), ...httpCertificateVerifier(generated.id, generated.name, endpoint));
1990
2005
  return { objects, rpcChannels };
1991
2006
  }
1992
2007
  function httpNetwork(plan, symbols) {
@@ -2525,7 +2540,7 @@ import {
2525
2540
  } from "@tsplc/compiler/ir";
2526
2541
  import { serviceOfPath } from "@tsplc/server";
2527
2542
  // packages/compiler/package.json
2528
- var version = "0.4.3";
2543
+ var version = "0.5.0";
2529
2544
 
2530
2545
  // packages/compiler/src/codesys/sources.ts
2531
2546
  import { existsSync, readFileSync } from "node:fs";
@@ -2955,7 +2970,7 @@ ${instances.length ? ` instance : STRING(${maximum(instances)});
2955
2970
  ];
2956
2971
  const { start, rest } = header(build);
2957
2972
  const helpers = httpMethods(writer).filter((item) => ["ByteLength", "Append", "WriteString"].includes(item.name));
2958
- const client = nativeHttp({
2973
+ const [client, clientExit] = nativeHttp({
2959
2974
  id: telemetryClient,
2960
2975
  name: names.client,
2961
2976
  ports: `VAR_INPUT
@@ -3116,6 +3131,7 @@ WriteString(text);
3116
3131
  ...failures,
3117
3132
  ...trace,
3118
3133
  client,
3134
+ clientExit,
3119
3135
  ...httpMethods(telemetryClient),
3120
3136
  ...httpCertificateVerifier(telemetryClient, names.client, endpoint)
3121
3137
  ];
@@ -5014,5 +5030,5 @@ export {
5014
5030
  publicationSelectors
5015
5031
  };
5016
5032
 
5017
- //# debugId=77F4BEFD0195C93064756E2164756E21
5033
+ //# debugId=74A8206EA117AB6864756E2164756E21
5018
5034
  //# sourceMappingURL=codesys.js.map