Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/types/pv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`");
});
});
23 changes: 20 additions & 3 deletions src/types/pv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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}`;
}
Expand Down
Loading