Example of a JScript
- g2 v! w& f. F N1 lvar vbOKCancel = 1; / Q* F' \7 K3 R3 T- Z
var vbCancel = 2;
4 z1 B$ X2 q3 ?( H2 Q% yvar vbInformation = 64;
+ r( m$ h3 ^1 k5 G( Gvar Finished=false;
: y% i, ?2 B1 N 5 T1 U( Q) [; q% V. B
var WSHShell = new ActiveXObject("WScript.Shell"); U7 E z9 S& Q4 C W) D3 i2 H) s
- x$ L2 u. ?) S/ kvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 7 t# Q8 a( V. i% s
5 E! N6 J4 e8 f& S; ^% @simple.SetLicenseType("Runtime");
8 q5 }1 h! K5 {$ t% X1 ? # Y, L1 [9 ^ [5 @2 @& I3 n8 I
try
$ R. f! x! T2 c: X: `& R8 X' ^. ]{
0 A! \$ r* n9 P! x // Enter the path to a model file! % {2 _8 Q7 p+ c& f
simple.LoadModel("C:\\Models\\Test.spp"); ) u# S" Q6 L! f5 T* b, y/ p5 V" ~! g
}
F; }5 K' S( ^: m% _2 v/ `2 l8 @catch (e) ) p/ ~* o) R8 Y: @0 |4 O, e
{
, D1 k( o c) m Q0 c WScript.Echo("Could not load Model!"); : d6 e0 ~5 r9 P2 o& Q+ T/ Z4 c( M
WScript.Quit();
2 [/ I9 I7 `6 F$ d& K1 D}
/ K; p. u! u8 G9 q . ?+ g P9 z6 m* b1 l% d3 j
try # c- @9 e; v0 i/ [3 k
{ 7 c( g% }. c. b2 l U
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
" Q# }3 u5 J) t9 u r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
5 D% G w- l5 h1 O if (r == vbCancel)
0 v3 b0 I! o( J, {8 H { ; z2 V* ^: @) E E7 H; c4 r# g# P/ B
simple.CloseModel(); 0 n+ C/ C; X8 |" K
WScript.Quit(); * d: l, {4 W- v6 p! v
} 1 w: V5 ?) k/ W0 R) Q2 _) ?. M) |
}
: n+ o# i/ m: g0 n9 u, P5 T S* t; Y
& i5 g- M% V/ R( [ L1 N6 Xsimple.StartSimulation(".Models.Frame.EventController");
: _. P* N' `% L0 J7 @
) k. G& w2 x& iif (simple.IsSimulationRunning()) # `4 s9 |2 H/ V* }" U2 v: F
WScript.Echo("Simulation is running!"); & m! ^0 U% A+ _8 F v
# p3 W* S# [" P9 {0 L; z// Wait until simulation is finished
$ `+ f+ j+ L9 J# c v% {while (!Finished) WScript.Sleep(2000);
: \/ a8 F, P( d) D5 Z+ \7 x0 K
7 z# C+ D- \' y. Fsimple.CloseModel();
8 z3 z2 o- h2 Y8 M$ s. msimple.Quit(); 3 `$ s8 j' m3 o7 A2 }: H; Q
WScript.Quit(); 2 u9 P' r5 F5 q
3 j" K3 T9 O9 w7 A0 z0 w& D( v
1 _; d$ P9 w! V9 U6 g) Xfunction RemoteControl_SimulationFinished()
6 c T, p, K* W{
; u/ V: ^! W! v6 j7 G" { WScript.Echo("Simulation Finished!"); |