Skip to content

Commit

Permalink
Bug fix/tsp 634 fix instr tree issues (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: GT, Shreya <[email protected]>
  • Loading branch information
Shreya-GT and GT, Shreya authored Jun 14, 2024
1 parent ae28826 commit 34bb2fe
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 352 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### Fixed

- If instrument connection address changes, it is updated in "Instruments" pane (TSP-634)
- Instrument tree is updated only when new instrument is discovered/saved/removed (TSP-634)
- **tsp-toolkit-kic-cli:** changed lxi and usb device info struct's instrument address field to same name (TSP-634)
- **tsp-toolkit-webhelp:** display.input.option() command signature has been corrected for all tti models

Expand Down
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,12 @@
"type": "object",
"title": "TSP Configuration",
"properties": {
"tsp.connectionList": {
"type": "array",
"default": [],
"description": "A list of previous instrument connections"
},
"tsp.errorLimit": {
"type": "number",
"default": 3,
"description": "Maximum number of consecutive errors to print in the terminal"
},
"tsp.savedInstrumentList": {
"tsp.savedInstruments": {
"type": "array",
"default": [],
"description": "A list of saved instrument serial numbers"
Expand Down Expand Up @@ -222,7 +217,7 @@
"view/item/context": [
{
"command": "InstrumentsExplorer.rename",
"when": "view == InstrumentsExplorer && viewItem =~ /.*Instr/"
"when": "view == InstrumentsExplorer && viewItem =~ /ToRemove.*/"
},
{
"command": "tsp.openTerminalIP",
Expand Down Expand Up @@ -345,4 +340,4 @@
"extensionDependencies": [
"sumneko.lua"
]
}
}
48 changes: 39 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ export async function createTerminal(
//USB
//This only works if selected from Instrument discovery
if (
!FriendlyNameMgr.handleFriendlyName(
!FriendlyNameMgr.checkForDuplicateFriendlyName(
IoType.Usb,
model_serial,
name,
ip
name
)
) {
return
Expand All @@ -95,11 +94,10 @@ export async function createTerminal(
if (msn != undefined) {
model_serial_no = msn.model + "#" + msn.sn //const to let
if (
!FriendlyNameMgr.handleFriendlyName(
!FriendlyNameMgr.checkForDuplicateFriendlyName(
IoType.Lan,
model_serial_no,
name,
ip
name
)
) {
return
Expand Down Expand Up @@ -135,6 +133,7 @@ export async function createTerminal(
ip,
IoType.Lan,
info,
name,
msn?.port
)
}
Expand All @@ -146,6 +145,7 @@ export function activate(context: vscode.ExtensionContext) {
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "tspcomms" is now active!')

updateExtensionSettings()
_connHelper = new ConnectionHelper()
_kicProcessMgr = new KicProcessMgr(_connHelper)

Expand Down Expand Up @@ -184,9 +184,12 @@ export function activate(context: vscode.ExtensionContext) {
*/

vscode.commands.registerCommand("tsp.openTerminalIP", connectCmd)
vscode.commands.registerCommand("InstrumentsExplorer.rename", startRename)
vscode.commands.registerCommand("InstrumentsExplorer.rename", async (e) => {
await startRename(e)
})

context.subscriptions.push(openTerminal)

//TODO: Connect `.terminate` in ki-comms
//context.subscriptions.push(terminateAll) TODO: This isn't connected in ki-comms...
//context.subscriptions.push(rclick)
Expand Down Expand Up @@ -224,6 +227,33 @@ export function deactivate() {
/* empty */
}

function updateExtensionSettings() {
const settingsList = ["connectionList", "savedInstrumentList"]
settingsList.forEach((setting) => {
if (vscode.workspace.getConfiguration("tsp").get(setting)) {
console.log(setting)
void vscode.window
.showInformationMessage(
setting +
' is deprecated. Select "Remove" to remove it from settings.json. If you wish to leave it, select "Ignore"',
...["Remove", "Ignore"]
)
.then((selection) => {
if (selection == "Remove") {
void vscode.workspace
.getConfiguration("tsp")
.update(setting, undefined, true)
.then(() => {
void vscode.window.showInformationMessage(
"removed setting: " + setting
)
})
}
})
}
})
}

/**
* For each workspace folder its creating file watcher for "*config.tsp.json"
* file so that if its get saved for any other process also its should able to
Expand Down Expand Up @@ -440,8 +470,8 @@ function startTerminateAllConn() {
void _terminationMgr.terminateAllConn()
}

function startRename(def: object) {
void _instrExplorer.rename(def)
async function startRename(def: unknown): Promise<void> {
await _instrExplorer.rename(def)
}

function connectCmd(def: object) {
Expand Down
Loading

0 comments on commit 34bb2fe

Please sign in to comment.