Smart Client scriptsprog og begrænsninger
[en] Smart Client scripts use a limited set of C# inside XML. When XProtect Smart Client loads a script file, it checks the file against a list of allowed language features and actions. If any part of the script is invalid, the script body and event triggers will not run; however, the <Login> block is still applied.
[en] File structure
[en] Save the file with the .scs extension, encoded as UTF-8. UTF-8 without BOM is recommended.
[en] Element | [en] Required | [en] Description |
|---|---|---|
| [en] Yes | [en] Root element. |
| [en] No | [en] File format version. The default and current version is |
| [en] No | [en] Login information. See Automatiser logon med scripts. |
| [en] No | [en] Script body. Runs once per login. |
| [en] No | [en] Event trigger. A file can have one per event. |
Bemærk
[en] Legacy elements such as <ScriptExtension> and any <ScriptLanguage> other than C# are refused by the script engine.)
[en] Special characters
[en] XML reads <, >, and & as markup. Wrap script code in <![CDATA[ … ]]>, which is recommended, or replace each character with its XML entity:
[en] Character | [en] Entity |
|---|---|
|
|
|
|
|
|
[en] Supported language
[en] Variables | [en] Details |
|---|---|
[en] Variables | [en] |
[en] Conditions |
|
[en] Loops | [en] |
[en] Operators | [en] |
[en] Strings | [en] Double quotes are recommended (single quotes are accepted by the engine but generate a warning and are not valid C#). Join strings with |
[en] Comments | [en] |
[en] Actions
[en] Action type | [en] Syntax | [en] Notes |
|---|---|---|
[en] Built-in actions |
| [en] Direct methods provided by the Smart Client script engine (for example, [en] The available groups are |
[en] Views, outputs, events, and PTZ presets |
| [en] The [en] Example: [en] These names are identical across all client display languages. If two items in the same group differ only by special characters (such as Cam 1 and Cam-1), they generate the same identifier, and only one is reachable; rename one of the items to resolve the collision. |
[en] MIP plugin actions, by name |
| [en] The |
[en] Actions by ID |
| [en] Language-independent unique identifier. Both names and IDs are listed in the generated script reference file when Include configuration items is checked, allowing you to copy the exact ID directly into your script. |
[en] To see all the actions available on your system, generate a script reference.
[en] Built-in functions
[en] Function | [en] Description |
|---|---|
| [en] Pauses the script without freezing XProtect Smart Client. Accepts 0–30,000 ms. |
| [en] Shows a notification in the notification area. It doesn't block the script or the UI. |
| [en] Date and time values. You can read |
| [en] Unique identifier operations. |
| [en] Writes to |
| [en] In an event trigger, returns the ID of the window where the event happened. Returns empty text for the main window, in the script body and in [en] Note: This function can return the ID of an embedded window (such as a view area inside a tab) which no |
[en] Event triggers
[en] Define <OnEvent> blocks inside the <ScriptEngine> root element to react to user actions and workspace changes.
[en] Event | [en] Runs |
|---|---|
| [en] After each completed configuration reload, once views and tabs have settled. Doesn't run at the first login. |
| [en] After a different view is selected, in any window. |
| [en] After a different view item is selected, in any window. |
| [en] After the selected tab changes, or a window switches between Live and Playback. Bemærk[en] Some workspaces, such as Alarm Manager and Exports, contain their own embedded view areas. Each embedded view area reports its creation using an ID that does not belong to a floating window. Switching to one of these tabs can therefore run ShownWorkSpaceChanged multiple times (for example, Alarm Manager has two embedded view areas and Exports has one, so switching to Alarm Manager can run the trigger up to three times). Your script should ignore unrecognized window IDs. |
[en] Event triggers are checked together with the script body. An unknown event name is an error.
[en] Event triggers become active before the script body runs and stay active until logout.
[en] An event trigger doesn't run again because of a change made by its own actions.
[en] Event names are case-sensitive.
[en] Each event type can be declared at most once in a script.
[en] View or tab changes initiated by the script body (
<Script>) also trigger these events.
[en] Limits
[en] Limit | [en] Value |
|---|---|
[en] Statements per run | 100,000 |
[en] Run time per run | [en] 30 seconds |
[en] | [en] 30 seconds |
[en] Runs per event trigger | [en] 60 per minute. Any more runs in that minute are skipped. |
[en] Iterations per loop | 10,000 |
[en] String length | [en] 65,536 characters |
[en] Each run of the script body or an event trigger has its own limits. If a run reaches a limit or an action fails, the rest of that run stops and the event is logged in MIPLog.txt, but XProtect Smart Client and any other event triggers keep running. When you log out or close XProtect Smart Client, it stops any running scripts.
[en] Not supported | [en] Use instead |
|---|---|
|
|
|
|
| [en] Verify script… before you deploy the script |
[en] Conditional operator ( |
|
[en] Prefix increment | [en] Postfix increment |
[en] String interpolation |
|
[en] Comma expressions, multiple variable declarations in | [en] Separate statements |
[en] Arrays, collection literals, and indexing | [en] Not supported |
[en] | [en] Not supported |
[en] Methods, classes, interfaces, namespaces, | [en] MIP plugin |
| [en] Use built-in script actions or a MIP plugin |
[en] Timers, | [en] |
[en] File, registry, network and process access, reflection | [en] MIP plugin |