Skip to content

Commit

Permalink
TSP-839 Fix issue with visa connection model and serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
GT, Shreya committed Oct 16, 2024
1 parent ee5aae2 commit 91c00d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Security -- in case of vulnerabilities.
-->

## [1.0.0]

### Fixed

- When entering only visa instrument address, connection is saved with correct model and serial number (TSP-839)

## [0.18.2]

Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export function createTerminal(
} else {
//VISA
//This only works if selected from Instrument discovery
if (name == "") {
name = FriendlyNameMgr.generateUniqueName(IoType.Visa, model_serial)
}
// if (name == "") {
// name = FriendlyNameMgr.generateUniqueName(IoType.Visa, model_serial)
// }
res = _activeConnectionManager?.createTerminal(
name,
IoType.Visa,
Expand Down
24 changes: 19 additions & 5 deletions src/resourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,28 @@ export class FriendlyNameMgr {
* @returns - unique friendly name for given instrument
*/
public static generateUniqueName(
io_type: IoType,
conn_type: string,
model_serial: string | undefined,
): string {
let unique_name = ""
let found = false
const io_type: IoType = FriendlyNameMgr.getIoType(conn_type)
const connections: Array<InstrInfo> =
vscode.workspace.getConfiguration("tsp").get("savedInstruments") ??
[]

if (connections.length > 0) {
connections.forEach((instr) => {
for (let i = 0; i < connections.length; i++) {
const instr = connections[i]
if (
io_type === instr.io_type &&
model_serial == instr.model + "#" + instr.serial_number
) {
unique_name = instr.friendly_name
found = true
return
break
}
})
}
}

if (!found) {
Expand All @@ -116,6 +118,18 @@ export class FriendlyNameMgr {
return unique_name
}

private static getIoType(conn_type: string) {
let io_type: IoType
if (conn_type === "usb") {
io_type = IoType.Usb
} else if (conn_type === "lan") {
io_type = IoType.Lan
} else {
io_type = IoType.Visa
}
return io_type
}

/**
* method checks and adds/updates new friendly name
*
Expand Down Expand Up @@ -327,7 +341,7 @@ export class KicCell extends EventEmitter {

if (name == "") {
verified_name = FriendlyNameMgr.generateUniqueName(
IoType.Lan,
connType,
_info.model + "#" + _info.serial_number,
)
name = verified_name
Expand Down

0 comments on commit 91c00d0

Please sign in to comment.