Example of a JScript ; w3 M1 i$ X2 d5 C/ R' A
var vbOKCancel = 1; ( Y- V: ]6 ~1 _
var vbCancel = 2;
7 G5 E4 U$ p) Y$ Lvar vbInformation = 64;
1 P- ], b7 s7 D$ ]# Uvar Finished=false;
3 W. t1 w; x& d# x ; n9 ^0 ^" U) g6 S7 u
var WSHShell = new ActiveXObject("WScript.Shell");
& x; q* N0 Z' |- T8 O; w9 y
, H3 i; w' T) i! Qvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
2 H2 W" I, |$ Z2 b p ; Q6 b2 y* s, B' ^6 d; a
simple.SetLicenseType("Runtime"); 1 ~4 p# e- W/ q0 ]
/ P( X z8 Y* S% @2 s. Wtry 9 n* @- \6 l8 R
{ ' U X7 Y) @0 c
// Enter the path to a model file!
8 J0 i" P; z l0 ^3 a simple.LoadModel("C:\\Models\\Test.spp");
% n a. P5 }1 X: N3 V} ( [; n; H5 Q5 V/ k& ^ d
catch (e)
]- R3 \1 x g) F a{
$ }+ Y0 l- H9 @5 ~& n% B0 i WScript.Echo("Could not load Model!");
2 I8 {' Z+ x4 q3 o/ ~# C WScript.Quit();
" }3 `: D# n6 x7 E. m/ U}
* \+ e# ?- V" g
; H- G7 v% F6 R# E0 ~try
6 X7 N% ~& A9 z, M7 t2 X' U' ~{
1 Q4 \) t: R% e simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ?0 a+ s$ B- e+ N* V8 V1 d4 g
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
5 n7 a2 ]5 D' W, E+ C% P if (r == vbCancel) ; }% F2 \) o! Q; R# ^
{ , H( o5 P5 g' T6 m1 |
simple.CloseModel(); 5 l, A/ B; a7 L/ r& _# ^% M
WScript.Quit(); , D Y& r( {1 [3 `! ]- J4 S
} ! k* g6 Y) E3 e g7 e' d! ~* \
}
; \* u. q) V3 p" C/ a ; D) r6 x3 D" T3 y# T1 n! T5 W$ K7 z
simple.StartSimulation(".Models.Frame.EventController");
9 u0 o* ^5 ]8 V. D4 C
8 `6 T' {% N- xif (simple.IsSimulationRunning()) 5 D% ?: t0 y0 `
WScript.Echo("Simulation is running!");
: [) B" @% k( z# F . T" |; y" z0 w, b, ?$ X: `; s
// Wait until simulation is finished 0 W K1 W$ N* _) K' G9 \( ]
while (!Finished) WScript.Sleep(2000);
! F: Y4 K5 U; Y+ u$ ~6 a4 |' k3 h
8 l ]0 x- h, U9 Nsimple.CloseModel();
6 D5 T2 `% Z! m$ f8 Usimple.Quit(); 9 t! w3 P- b7 o' g
WScript.Quit(); * W2 y; x7 f) _6 D" u
. i2 N" d1 S, a* O 9 Z2 {/ J& f9 v7 ?6 n3 }
function RemoteControl_SimulationFinished()
. ^5 }1 R6 |. l+ E8 B: v4 `7 n' u5 R{ $ x' i9 _! @% ^; o
WScript.Echo("Simulation Finished!"); |