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); 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`"); + }); }); diff --git a/src/types/pv.ts b/src/types/pv.ts index 112c7701..230f43bd 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,8 +48,18 @@ 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("`") && + !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 if (this.name.startsWith("=")) { + return this.name.replace("=", "eq://"); } else { return `${this.protocol}${PV.DELIMITER}${this.name}`; }