Example of a JScript
! I% Q- c# _+ q6 t, ovar vbOKCancel = 1; ' b( I: D& M' A3 Q9 [1 |
var vbCancel = 2; : ^2 m1 K2 [0 o. \. P
var vbInformation = 64;
% t: |: \/ e) zvar Finished=false; 6 y0 N& c X; i1 i6 X. _( K7 H5 z
) E* i7 E- r P: pvar WSHShell = new ActiveXObject("WScript.Shell");
% o; b ?6 P9 T2 [, f3 u: V 4 P9 A5 O+ Y$ a2 x3 f2 ?; i
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 1 F+ C1 e3 h: j7 O% A
8 i0 T, j9 ?/ Z' P
simple.SetLicenseType("Runtime");
9 J9 R; n' S9 W
t- V- {" t7 L% U r; [" B$ \6 Wtry ; T+ W4 u: ^6 E4 w) N, D- V1 D/ n
{
8 Q9 X& i: t9 o. q // Enter the path to a model file! % F7 A: f" U+ z! o
simple.LoadModel("C:\\Models\\Test.spp");
, x; A- P; s9 Y6 e4 J& C} ) F& o6 D7 {& Y) |) z# ?$ a. |, A
catch (e) 3 Z: w9 S3 r& n. S' }8 E
{
6 k* J1 B/ e8 c WScript.Echo("Could not load Model!");
; n: B- D# W$ k2 c7 F$ D8 t WScript.Quit();
& B' z. m6 r' g7 V8 n& E, J}
- y; Q) i6 a& F$ g$ Y" N4 V
+ Y6 @4 H+ r6 k% etry 7 m$ s: E# N5 A' v2 E' A4 c
{
& ]8 H R, C; s7 c3 E+ d simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { % b% m: ~4 K; N1 _) E$ e0 u8 H9 \
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
7 r6 f: R6 m8 q1 Y3 ~6 C' F+ m if (r == vbCancel)
! O4 f& {. _7 y5 g: T0 ] {
" l# L" [6 [/ i, K9 p simple.CloseModel();
# X% |& l7 [% W% e! R0 U o7 J8 K WScript.Quit(); & e. F* d$ [; y1 N. l
}
, W: {$ v5 ]" s& @4 }} $ h* v7 O w6 J9 M' y3 c
2 j$ T' t2 r3 G$ S# esimple.StartSimulation(".Models.Frame.EventController"); 8 U+ ~) k4 C/ r& w- t3 X+ Y& c6 \7 z
# c5 N( E) d! ?+ l' U- |# E+ wif (simple.IsSimulationRunning())
% r0 W" c, G6 i WScript.Echo("Simulation is running!"); 5 g# Z/ Z: B) W" G3 c" ~: a9 B! ^
; a/ S* Q! b! i7 t// Wait until simulation is finished 2 q/ \* \7 r4 }2 F; o
while (!Finished) WScript.Sleep(2000); : L9 S/ G! W$ Z) E U; D7 [/ l! \7 `
* [- C! _9 v4 Q" C
simple.CloseModel(); 5 V( G6 G* Y" d3 H4 M
simple.Quit(); $ Y: y6 s V3 h
WScript.Quit(); 9 o# c! P- B' n" {" _0 A D+ I L
4 r* I- L3 ~6 i+ w+ |2 n
, x& V. A+ r3 L+ hfunction RemoteControl_SimulationFinished()
* i% `+ E! ], G" a6 e* G* p{ 8 j2 }! q0 H( j* V' n
WScript.Echo("Simulation Finished!"); |