Example of a JScript
; r# ^: ^0 @; x8 v; {var vbOKCancel = 1;
$ q! W: t; S) U7 S; Gvar vbCancel = 2;
9 H3 i) S8 r. b- x: vvar vbInformation = 64; ' `5 y& T2 @+ V y
var Finished=false; , }- i; {6 }' ]% @
' J( ~. H; D: B$ A! i1 f% C
var WSHShell = new ActiveXObject("WScript.Shell");
@$ @( E5 b- [0 j! u; k" R " e; c/ J0 g& V1 [" Q! Q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
8 X. @, ]3 ]! w. p; W! F , Z2 Q( S, f- `* H& V5 A
simple.SetLicenseType("Runtime"); & _* u; J7 ~4 v9 v2 a7 m: Q/ d7 }7 K
! f" v+ ?: T) b0 B1 W
try
" P3 r1 }; @) z3 \, Z, p8 c% F{ * B% b. K7 P; J1 O4 z, r
// Enter the path to a model file!
& g4 |# i: }/ A. X4 w' u( l M simple.LoadModel("C:\\Models\\Test.spp");
) n, v+ G% u; Q6 q7 q# `} 9 Y, r4 L: F& r* D6 R1 {
catch (e)
. B$ x- o- Z) K% X6 b{ + k( A4 [7 p. y( d# p, e# x2 }
WScript.Echo("Could not load Model!");
( W9 L6 k# I$ w% m WScript.Quit(); ; m# k8 e6 Y5 I$ b/ j& S
}
; m# x; k' s! I) S8 K" A$ a
! e% E2 G' p0 G3 t0 g8 v6 |) ]try , b8 x' r* [ y# C$ e
{ 6 @$ ]3 p8 g, W5 M+ A5 J4 A
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
9 i! N* t5 V1 u* T2 W( X: S6 s r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
9 Z% {! y1 C, a if (r == vbCancel) 2 L( c; h5 r; b8 Q o. f
{ 0 S4 y& t8 }9 h# b
simple.CloseModel(); 4 k' p9 w; [# j9 ?
WScript.Quit();
! {/ ?/ L& ^& K9 {; ~7 { } 1 V k% P+ z! l4 R+ Q( n
}
0 F5 ?+ w4 G3 k0 _3 v
8 B: L1 J' @& g rsimple.StartSimulation(".Models.Frame.EventController"); 6 | i/ O% x) V6 C" @
6 i; K: n( g F
if (simple.IsSimulationRunning()) & Z1 E0 l4 Q( c% G( w
WScript.Echo("Simulation is running!");
; ~1 s. d% u0 W' {6 y1 _4 \8 l4 m : \. `5 A. ^' n: f6 R0 d7 w; d9 H
// Wait until simulation is finished + U9 {; P4 a1 C# U" K
while (!Finished) WScript.Sleep(2000);
T6 B q1 v4 U9 p1 g. G / E/ G- L( E7 J) o$ @( |6 G9 f9 @
simple.CloseModel();
+ \* d' R1 x: x7 v) |2 ssimple.Quit(); , R1 e2 H3 @7 D0 c# {! Y7 a0 A
WScript.Quit(); 5 k q- x0 E& M
2 k% R$ P! |7 P' J& e4 \1 [+ A
' e j; c1 b* v) }
function RemoteControl_SimulationFinished()
, n0 \2 m) s2 {: G{
% Z1 }4 A9 x, h WScript.Echo("Simulation Finished!"); |