-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUSAGE_EXAMPLE.ts
More file actions
52 lines (41 loc) · 1.7 KB
/
Copy pathUSAGE_EXAMPLE.ts
File metadata and controls
52 lines (41 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Example: How other extensions use the Core API
import * as vscode from 'vscode';
async function useWinCCOACore() {
// 1. Get the Core Extension
const coreExtension = vscode.extensions.getExtension('winccoa-tools-pack.winccoa-core');
if (!coreExtension) {
vscode.window.showErrorMessage('WinCC OA Core extension not installed');
return;
}
// 2. Activate it (if not already active)
const coreAPI = await coreExtension.activate();
// 3. Get current project
const currentProject = coreAPI.getCurrentProject();
if (currentProject) {
console.log('Current Project:', currentProject.name);
console.log('Version:', currentProject.version);
console.log('Project Path:', currentProject.projectDir);
console.log('OA Install:', currentProject.oaInstallPath);
console.log('Config Path:', currentProject.configPath);
// Use the paths for your extension
// e.g., read config file, find scripts, etc.
}
// 4. Listen for project changes
coreAPI.onDidChangeProject((project) => {
if (project) {
console.log('Project changed to:', project.name);
// Update your extension when user switches projects
} else {
console.log('No project selected');
}
});
// 5. Get all running projects
const runningProjects = await coreAPI.getRunningProjects();
console.log(`Found ${runningProjects.length} running projects`);
// 6. Switch to different project
await coreAPI.setCurrentProject('DevEnv');
}
// In your extension's package.json, add:
// "extensionDependencies": [
// "winccoa-tools-pack.winccoa-core"
// ]