Example of a JScript ) f' W7 m$ l( c3 }
var vbOKCancel = 1;
$ j$ G! j3 N7 E! L, B, M, nvar vbCancel = 2; C: D8 J- C" q# C3 H
var vbInformation = 64; , `. U$ [8 b" S- f) x
var Finished=false; 2 X; F: w! f3 y1 V/ D: k
5 p: _7 F0 {6 ?- Y. t1 ^3 V
var WSHShell = new ActiveXObject("WScript.Shell"); 0 S3 w5 b" r" i
! F: K; y A1 b1 I
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
$ G) D) n/ V, z- a7 j! { * ?7 K( w5 |1 Q
simple.SetLicenseType("Runtime"); 4 s7 j9 w4 C9 S) @3 n$ F
3 c$ r6 k4 j: @+ w
try ; D, ]9 R% M/ r; R
{ " ?2 [3 X( \0 \# @ J) Q \
// Enter the path to a model file! ' I( w8 `' v& u3 B9 d
simple.LoadModel("C:\\Models\\Test.spp");
$ L4 t# k1 ~6 I9 \8 j$ ^}
. I& w0 S/ c* q$ q5 Xcatch (e)
3 v4 K3 K0 S0 R& f' f! y; F{
" d7 j. y. d- }; s3 C$ U WScript.Echo("Could not load Model!"); T: ]5 t4 C* O
WScript.Quit(); & D) ?: _2 b/ W! j
}
8 y5 P" [/ g! Q8 I* Y& `/ A / S) p& h" T+ E% [. E5 [
try
- S( `/ C9 O1 g{ o; D9 f- ]3 A% M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
1 J. Y! U% q- l8 I r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 |4 N% ]6 k' h& t4 s4 ?4 C if (r == vbCancel) : q% T; W H& @ b) R! t% o6 M
{ : h9 M4 T, h) `7 S
simple.CloseModel();
' C7 |0 G. P: P) t! W3 r. W. n' O WScript.Quit();
" q9 K9 G6 |7 v$ G9 o C# g( m }
6 [& M/ K. C1 l" g: l} . L; ?/ }, e5 ]0 O! q
& V& K! A3 v/ i6 e) o9 Gsimple.StartSimulation(".Models.Frame.EventController"); . l7 y/ y, z' }% v+ ]" x& G9 d7 Q
. g5 M- T0 Q: N
if (simple.IsSimulationRunning())
! i+ u8 }1 ^1 x/ k2 Y WScript.Echo("Simulation is running!");
7 S) D# i9 \ S2 L6 C
8 d' T1 Z' p1 j. _4 y+ X& D9 s// Wait until simulation is finished
) w) H( ^: P1 p& y2 D- Dwhile (!Finished) WScript.Sleep(2000); * Z9 Y) \) x" j! d& `/ m
4 O5 H5 U, u3 a0 j9 x4 Ksimple.CloseModel(); * N9 k4 t3 K) U6 K: Z: \1 X% A; W! V
simple.Quit(); / E, K5 a$ B5 _( g* h. t6 \' K
WScript.Quit(); 6 k" S( i# V$ ]- W5 J& Z# A; W0 |3 R+ C
; L5 Q, T* |7 z- }' ?9 C
9 n) m" v# Q+ Z6 M7 }! |4 yfunction RemoteControl_SimulationFinished() + \6 B: P$ u, a5 c+ l* V
{ & M" `2 W* _/ S4 I
WScript.Echo("Simulation Finished!"); |