Example of a JScript
8 X% o8 L; c; E4 W$ x& V) L1 O0 }! rvar vbOKCancel = 1;
+ ]* r6 @' H7 bvar vbCancel = 2;
7 f8 _: }; E- h# Yvar vbInformation = 64;
& I5 u- [' f. ~9 A* n, K! |) e3 Tvar Finished=false;
2 t! M3 l. Z9 ^7 i; Y
! E e$ p3 t9 o* Mvar WSHShell = new ActiveXObject("WScript.Shell");
: X, d5 {; A+ @$ x+ h _
1 e& w) r' N" y& ?6 f) uvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); Z/ C$ x6 _. H4 f/ d
; O! a5 r0 {7 q( x! [1 j7 X
simple.SetLicenseType("Runtime");
1 P; F6 q1 ~/ I2 A 4 K" X7 L/ \3 S$ V
try
- {* w7 @1 ^) a9 K: k1 B{ \( H! o* l9 Q
// Enter the path to a model file!
z* n, V; o0 {* |+ h! I: n simple.LoadModel("C:\\Models\\Test.spp");
: g7 V5 \6 R9 ~* p}
8 E) f5 N* u Z+ Y3 o/ ycatch (e)
* c/ k1 d# s/ Q) m{
" s. ?2 T# o; k WScript.Echo("Could not load Model!");
7 m9 n0 W/ l* H' Z6 m) E( ]* z) a WScript.Quit();
) \1 P6 S: }6 d* P}
0 G( Z7 |; o% m+ X6 \* M / E: ^- H% ?" j- s# }
try
6 Y) y! V {( ~5 z/ s. U5 i6 F- B{ ?7 l( ^3 y, h u
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { Z0 h3 C$ a& i H$ {9 ?
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
0 f& G6 c& u9 a4 w1 v4 s; @1 V if (r == vbCancel)
) Z t; l8 X5 Q: E( X {
( `# F C& P' W- b U7 i simple.CloseModel();
3 C- x% q8 k: m! U( ?" K5 l WScript.Quit();
* u" S3 |: E! f; w4 i, o } ) n9 _% |$ c( v
} 8 c7 n, `) j# k i
5 ?3 m2 {. _, h
simple.StartSimulation(".Models.Frame.EventController"); : ?8 L/ p: y% ?7 n' b( E
r) A+ w& O$ b: v& \- `3 Cif (simple.IsSimulationRunning()) / g" B' G! H4 r+ M" e) T2 i. b( E
WScript.Echo("Simulation is running!"); # Q2 ], R% E, L9 d" s
: K |- m( P' q0 e5 c, v* b+ r
// Wait until simulation is finished . ?- k. o7 F+ o2 v4 X
while (!Finished) WScript.Sleep(2000);
( c7 C" l4 p) ?$ T0 ?
. b- Y* R0 A) e/ C. hsimple.CloseModel(); ' ?' w1 w4 H* H+ h" V c
simple.Quit(); + H; B8 ]. J) x. Q; _6 z; @2 |
WScript.Quit();
0 Y$ u6 i, T! C& @7 |( S* d
+ z' ]- p0 z0 N( U 4 h# G- g( {+ y6 f2 T* U
function RemoteControl_SimulationFinished()
$ N$ O2 o& I2 Y% s{
$ Q- ]5 f/ F8 \0 i; K6 P WScript.Echo("Simulation Finished!"); |