Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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`");
});
});
14 changes: 11 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,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("`")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor point - it looks like you can also create a formula using a single quote (i.e. ') as well as with a backtick, e.g. =3+4*'sim://ramp'. This works in Phoebus and PVWS so maybe we could just add an addition && to check that it also doesn't include a '?

return this.name;
} else {
return `${this.protocol}${PV.DELIMITER}${this.name}`;
Expand Down
Loading