Example of a JScript * b" M7 v/ E, p3 z7 R% c7 p
var vbOKCancel = 1; 5 M: B' r7 K# Z7 p0 c
var vbCancel = 2;
/ L. d4 n! H T- y2 L5 l' P! kvar vbInformation = 64; % Z) _( j- c- B$ D# @
var Finished=false;
% h P9 m7 V4 s% c8 n5 ~! c" s( v5 u , ^/ T* Q( n6 I% q5 w
var WSHShell = new ActiveXObject("WScript.Shell");
y/ S8 ~( ~- ~7 A 6 G3 @, ~2 S2 ]9 @5 J5 e
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 0 q `5 I8 i" y" t0 L* b4 I
$ C, T6 u% \3 J' d* p6 jsimple.SetLicenseType("Runtime"); 7 a, W a9 @2 [. Y2 ]& z
8 A# j! [& p2 a. gtry
7 y$ i9 ]: p; D; V# i/ a) x3 T. o{ ' F& B$ \+ z1 C2 m* A& N
// Enter the path to a model file! 0 I9 j2 O9 n$ p! Z' n2 |
simple.LoadModel("C:\\Models\\Test.spp");
7 v: m- `$ _# t h2 p! n} ' U' B$ c* F5 X" p) G
catch (e) 1 p3 @ @7 Z! J
{ % ]2 }; Y d- m& S0 p# x' v8 Z" L
WScript.Echo("Could not load Model!");
) H+ H. g3 T3 t$ W WScript.Quit();
8 U; E! e+ w$ H" E8 x g- b, _! n; M' n}
; F8 G; u; m, c- B# O z; B , N6 D z. \$ g9 v) h
try
7 @* t$ m8 s- v5 Z f# Z{
; u: e" K( R% [4 ~ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 G) f: j1 o* V" k r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
: G4 p+ ?4 A/ o4 u- }+ B if (r == vbCancel)
# h$ F+ J# e' l) G { M4 D5 _) g' { ]. ]
simple.CloseModel(); ! `8 E; O& T! e6 i0 a
WScript.Quit();
+ h6 }0 `% f! q0 B1 D4 p6 l }
( Q0 ?4 Z3 Z) v: w3 z} z/ W* w9 r1 z0 C
2 D* p% L( x) [$ S1 f3 T
simple.StartSimulation(".Models.Frame.EventController"); 1 F9 i4 y( J( K% ?) ?4 b+ H. E
' r2 p1 |& N: {/ P. Q& a
if (simple.IsSimulationRunning())
N6 z% ]6 J, O& V WScript.Echo("Simulation is running!");
- l; F+ ~; d3 h& a8 |9 P
, g# H" O9 w; g. L. I+ u// Wait until simulation is finished
0 \/ s. D1 c) Fwhile (!Finished) WScript.Sleep(2000); 3 ?8 m1 }% V! h, Q$ p- [( N, A
* K! i& g4 ]( g5 `: u4 s: Bsimple.CloseModel(); + S8 F1 }$ K% i' ?' T
simple.Quit(); ' c' Y/ I) |9 F, A. a& D3 c3 \
WScript.Quit();
( S* z5 y6 C* n2 B8 P$ n+ ]
# M' m5 p7 C& F* B% R5 h
) x' y/ r6 J$ V* x" K9 ]2 s4 w% vfunction RemoteControl_SimulationFinished()
' x$ T4 \+ y. ^9 V( w{
/ }0 |9 n* K6 E6 o; } WScript.Echo("Simulation Finished!"); |