Example of a JScript
4 ~/ H3 e/ Y* ` y2 Wvar vbOKCancel = 1; ! H n9 x' u7 M5 o4 |
var vbCancel = 2; ) }+ r# Q$ v9 K) [
var vbInformation = 64;
, i! P3 ] `2 y3 C# Y/ jvar Finished=false;
; n) N; z3 |* u7 O2 m$ v: x- Y8 ^9 R
# d% `9 T+ n; ?; F9 Bvar WSHShell = new ActiveXObject("WScript.Shell");
# r( e: S* T5 w* C3 w- |' C8 @& p6 R
$ Q6 A8 {& j' Z/ w, J" Tvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ( t B4 v1 `1 D0 e8 M4 [+ l& B) u
+ G% ?8 u! L7 q! {& u7 {0 ^& h+ ^& Xsimple.SetLicenseType("Runtime"); 9 ^8 a& z1 K& w( T0 j
7 k7 O. Q( J% W& ?8 G5 Ltry
% r; d2 `+ A0 H: r/ F{
* I7 A+ j9 |0 R- [& H4 P // Enter the path to a model file! * t" G5 H+ z- |/ m/ J0 R
simple.LoadModel("C:\\Models\\Test.spp"); ( Y6 s4 L" N! N3 t. ]
}
r3 ?8 i M) c' j: ^6 |0 }catch (e) 6 j4 Q- Q( D% w- r* Z4 f
{ - G' e0 ~7 W& k. s7 ^4 z* l* `. n
WScript.Echo("Could not load Model!"); & g+ L+ ~) R. g' I0 T% E! T9 O
WScript.Quit();
. [+ K. E2 K: O# r- g* t} . P# W$ g) ^5 k4 w2 z# g
+ A) L+ {8 K! d ^9 {! ^- M/ Ktry ! q4 _- x$ C3 ~9 R2 d: H
{ 1 t9 y* C" S4 z+ Z _- A! d, J
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { - g1 l* n. J! [% Y+ Y! W
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); + ^! Z1 U' U8 K4 q- ?6 U( |* w' a
if (r == vbCancel)
, H0 i% P' m0 w { @/ Q# Y7 t) h! r6 P- ?; e
simple.CloseModel();
) l, J ?8 A% p WScript.Quit(); ) u- B: R- {0 a4 o; r3 c. T q
}
! M& k6 h6 S, m- s, J9 ~}
! M( P0 O" a$ `6 S9 A% C* T/ z 7 e% M% U. H5 i& i6 o! Q" n7 T8 T
simple.StartSimulation(".Models.Frame.EventController"); + o& a7 M$ c! t& F2 a
0 ]2 I* A2 v" ^6 z2 o% d
if (simple.IsSimulationRunning()) % s6 l1 |' [; N8 z8 f1 S& R
WScript.Echo("Simulation is running!"); 5 e" t+ N8 r: U" |% ]
6 k& {8 _7 L S
// Wait until simulation is finished
2 v2 d, g8 P: G3 O0 D: I3 ]while (!Finished) WScript.Sleep(2000);
7 I$ P. ?% G2 [$ |2 B) b( f
& p5 ^( P' d+ _& r. Osimple.CloseModel(); 2 o, w( A' A8 d) t% l1 V
simple.Quit(); ( O" H0 N, M/ y0 T
WScript.Quit();
9 |; G, }, i7 ~- Z
& q H. H8 I# {* v. R. W# p8 g 6 A; A+ |1 z( r' P+ I9 t4 X1 z
function RemoteControl_SimulationFinished() + S8 ^' p$ f; ~: J2 a
{
& M6 V" r5 c* ?9 N, @" U) r1 f4 z WScript.Echo("Simulation Finished!"); |