From be84fcd6f0c8038393f68169790d08719ab33d2f Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 11:24:49 +0100 Subject: [PATCH 1/6] Updated PV parser to correctly parse PV formulae --- src/types/pv.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/types/pv.ts b/src/types/pv.ts index 112c7701..be7666a8 100644 --- a/src/types/pv.ts +++ b/src/types/pv.ts @@ -24,9 +24,16 @@ export class PV { * PV.parse("pvName") */ public static parse(pvName: string, defaultProtocol = "ca"): PV { + if (pvName.startsWith("=")) { + return new PV(pvName.slice(1), "eq"); + } if (pvName.includes(PV.DELIMITER)) { - const parts = pvName.split(PV.DELIMITER); - return new PV(parts[1], parts[0]); + // "protocol://name" -> ["protocol://name", "protocol", "name"] + const parts = /^(.*):\/\/(.*)$/.exec(pvName); + if (parts) { + return new PV(parts[2], parts[1]); + } + return new PV(pvName, defaultProtocol); } else { return new PV(pvName, defaultProtocol); } @@ -41,7 +48,8 @@ export class PV { public qualifiedName(): string { // This can happen if the name is substituted by a macro // after the PV object has been created. - if (this.name.includes(PV.DELIMITER)) { + // Need to make sure that the PV.DELIMITER is not associated with a nested PV. + if (this.name.includes(PV.DELIMITER) && !this.name.includes("`")) { return this.name; } else { return `${this.protocol}${PV.DELIMITER}${this.name}`; From 40b86249143a350508990a4c0e51263e08e596ca Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 11:25:03 +0100 Subject: [PATCH 2/6] Added test for PV formula --- src/types/pv.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types/pv.test.ts b/src/types/pv.test.ts index 7381c308..0ccecdee 100644 --- a/src/types/pv.test.ts +++ b/src/types/pv.test.ts @@ -13,4 +13,8 @@ describe("PV", (): void => { const pv = PV.parse("pvName"); expect(pv).toEqual(new PV("pvName", "ca")); }); + it("ignores nested pv", (): void => { + const pv = PV.parse("=3+4*`sim://ramp`"); + expect(pv.qualifiedName()).toEqual("eq://3+4*`sim://ramp`"); + }); }); From 0e44329d7a36dd9a164964553db08c94113ecc54 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 11:25:16 +0100 Subject: [PATCH 3/6] Added "eq://" to list of plugins --- src/redux/store.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/redux/store.ts b/src/redux/store.ts index 108854c0..df12ed81 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -28,6 +28,7 @@ if (PVWS_SOCKET !== undefined) { plugins.unshift(["sim://", pvws]); plugins.unshift(["ssim://", pvws]); plugins.unshift(["dev://", pvws]); + plugins.unshift(["eq://", pvws]); } const connection = new ConnectionForwarder(plugins); From 9adc42ac864ffdf1d3be0bc9dcd5d809f815c7e4 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 13:32:41 +0100 Subject: [PATCH 4/6] Updated PV.qualifiedName() to check for single-quotes and substituted formulas --- src/types/pv.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/types/pv.ts b/src/types/pv.ts index be7666a8..7ef80a60 100644 --- a/src/types/pv.ts +++ b/src/types/pv.ts @@ -49,7 +49,14 @@ export class PV { // This can happen if the name is substituted by a macro // after the PV object has been created. // Need to make sure that the PV.DELIMITER is not associated with a nested PV. - if (this.name.includes(PV.DELIMITER) && !this.name.includes("`")) { + if ( + this.name.includes(PV.DELIMITER) && + !this.name.includes("`") && + !this.name.includes("'") + ) { + return this.name; + // In case the name has been substituted with another formula + } else if (this.name.startsWith("eq://")) { return this.name; } else { return `${this.protocol}${PV.DELIMITER}${this.name}`; From c9bf5f612d637baf1f68b061da06035251b79b92 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 13:39:44 +0100 Subject: [PATCH 5/6] Updated PV.qualifiedName() to check for substituted formulas starting with "=" --- src/types/pv.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/pv.ts b/src/types/pv.ts index 7ef80a60..08631245 100644 --- a/src/types/pv.ts +++ b/src/types/pv.ts @@ -56,7 +56,7 @@ export class PV { ) { return this.name; // In case the name has been substituted with another formula - } else if (this.name.startsWith("eq://")) { + } else if (this.name.startsWith("eq://") || this.name.startsWith("=")) { return this.name; } else { return `${this.protocol}${PV.DELIMITER}${this.name}`; From 54ba5d2ff92d6a8c31612fbc6dbba84fdbe55da7 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Tue, 13 May 2025 13:43:00 +0100 Subject: [PATCH 6/6] Replace "=" with "eq://" in substituted formulae --- src/types/pv.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/pv.ts b/src/types/pv.ts index 08631245..230f43bd 100644 --- a/src/types/pv.ts +++ b/src/types/pv.ts @@ -56,8 +56,10 @@ export class PV { ) { return this.name; // In case the name has been substituted with another formula - } else if (this.name.startsWith("eq://") || this.name.startsWith("=")) { + } else if (this.name.startsWith("eq://")) { return this.name; + } else if (this.name.startsWith("=")) { + return this.name.replace("=", "eq://"); } else { return `${this.protocol}${PV.DELIMITER}${this.name}`; }