Example of a JScript & L; K8 P8 Z3 n
var vbOKCancel = 1;
& e5 i$ z! B; A3 ]3 R5 ?. yvar vbCancel = 2;
3 Y/ z% k4 | E, G2 gvar vbInformation = 64;
2 q; O8 y! w2 {, Fvar Finished=false;
p" L! k% r, Q+ O { 7 H% K' U* Q; L) ?
var WSHShell = new ActiveXObject("WScript.Shell");
3 c. k, Z! A0 O; d- a! D ; I# w( N7 U1 V- T4 b5 z
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 1 }" q9 Q- q! S0 [8 ~9 [! F- s
( U- c1 ], G, R0 z: Lsimple.SetLicenseType("Runtime");
5 n1 f M1 A7 [
9 I7 b, Y1 U+ Y! V+ u: Ztry
. ?. X$ D0 k/ y7 |1 v{
0 }2 H1 k5 I) v) b% k3 A // Enter the path to a model file! ! z9 J. s: b& u+ j! R/ }
simple.LoadModel("C:\\Models\\Test.spp");
9 P3 u( p G& T1 n5 D* ~6 G}
& n q% s: O' {# d2 e; i/ Icatch (e) + ~3 U: x$ t/ K8 m
{ # h! q4 l& I) Q4 A1 ?% A. M
WScript.Echo("Could not load Model!");
* g; h5 y/ W( ~: q' t) V WScript.Quit(); 0 y$ V: {( M/ W% C9 i) L
}
, m6 n( t' W) k* ]" y
) P+ o z5 M& B# D6 S, P; r# Ntry % ^8 g4 H% p) h/ }
{
2 T5 N& X4 b( l& z. F( o; z simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
" w3 N5 \& K% h9 H+ Z d r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
7 C. m4 T6 t$ v* c5 _. t8 {4 G if (r == vbCancel) 5 a* v+ M. h% f2 Q5 l) |$ u
{
9 R7 a: }2 Z' W( g( n6 Q& o simple.CloseModel();
1 _7 K" d6 |! e, x WScript.Quit(); 1 K3 ~. z1 P1 v) U! K9 I9 I
} : q& m" K1 Y0 e! f( I$ y
} 9 M8 }0 `# k% F) |# v
S% Q5 |; ?% T# ]) k* B, W
simple.StartSimulation(".Models.Frame.EventController");
1 F8 A: H# L' H7 [" C
O: v8 \+ X8 z3 @; n+ |$ Nif (simple.IsSimulationRunning())
( @& i2 s" h7 t" L6 j) S( f: w* j WScript.Echo("Simulation is running!");
# x% M9 `+ j: G7 y% s C
: f+ G+ p; q j& d) ]6 @; r& @' F// Wait until simulation is finished
6 ~3 V* @! a! H# q' w# `while (!Finished) WScript.Sleep(2000);
4 y/ D2 s* y* o- \7 q; R 0 Z. ]8 j5 b: p! R
simple.CloseModel(); 0 c0 T3 y X- ]( L" I) G
simple.Quit(); 1 `; Q# ]6 b6 g- f2 b1 E
WScript.Quit(); + y) G6 ^. F; S( q# p. V0 b
8 G. C$ G1 P, R ; G; d, H. X& N3 N" |
function RemoteControl_SimulationFinished() # e" @3 Q4 o3 o w4 [1 H, u3 X
{
- t' C% u! ^* E3 a/ j" a) I WScript.Echo("Simulation Finished!"); |