Example of a JScript
& N9 O! z% \ S$ x3 Vvar vbOKCancel = 1; 1 d5 g R* a$ c4 [+ y9 P8 q) z2 [
var vbCancel = 2;
" N$ X B4 K' U6 _var vbInformation = 64;
7 M2 u+ `: ~6 j2 g1 d( w, P4 gvar Finished=false; - X6 }3 x. p. T/ H4 @) q2 ]
) a# K+ G/ i! S0 C) s3 G' j$ p, l
var WSHShell = new ActiveXObject("WScript.Shell"); 8 e, i% g# j- E! d6 u4 P- P' ]
+ O$ L* R5 E! h/ S$ xvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 8 F. W; b6 z: b4 V5 e& c
+ w: f: J% S3 Zsimple.SetLicenseType("Runtime"); + z q' \' a0 v: o+ b4 D
9 e6 }" |- t- s: w n6 v9 a
try 1 n( ^ ]( o! ?
{
3 w Q9 M! E- e* Q2 L+ Q // Enter the path to a model file! ; f4 n1 u) u8 g9 n. U. E, ^
simple.LoadModel("C:\\Models\\Test.spp");
8 l; z1 f3 m j/ ] m1 `1 S, F} % y8 f& B4 l/ Y
catch (e)
( L5 u/ [7 t; Z+ b{ 7 q0 i Y6 D* H0 b/ F
WScript.Echo("Could not load Model!"); 7 w8 x- }) C! i# y
WScript.Quit(); 5 E3 `0 Q/ g: _3 q
}
1 {* I* e0 Z1 Q" W$ U5 W" N) }5 W
+ f# `" w5 c# y6 R6 T. Jtry
! p7 P3 e% Z+ ?" Z% S{
* f; s5 n, f. k$ \: g. J simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
7 n4 H0 R0 P0 _& o. {" H4 [ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); " t, h- L5 y t3 }. ]3 ^
if (r == vbCancel) - n* C* E7 z9 H1 ^) l
{ ) Z8 _+ U9 p* u. x4 `' c1 V
simple.CloseModel(); * q" B. N! Q |" \& x3 g
WScript.Quit(); % m( G7 B- p9 C# u! X6 j8 Z4 @6 k
} 5 P h, C. E, @/ ~; b4 H+ i! U. \- b
}
! {9 J& S: b9 Q" L& K - f9 M8 _1 z$ N3 I
simple.StartSimulation(".Models.Frame.EventController");
% N" U8 l$ v$ [' D9 A- W
: W* V [) v- } Xif (simple.IsSimulationRunning()) w2 u0 y3 y, h& V
WScript.Echo("Simulation is running!");
# v& w+ B t* h' T) ]2 a( A; D
/ n9 z. q: s* z6 o// Wait until simulation is finished
; s! e" T8 D3 X9 t& c) y2 A( swhile (!Finished) WScript.Sleep(2000);
9 a/ |# a5 U* J 5 d' e% a8 `, U3 D; }2 [
simple.CloseModel(); 5 X' r" L8 Y$ C# o/ v
simple.Quit();
; m/ S0 u& p, E6 Q5 gWScript.Quit();
5 g" |$ }1 ]7 S$ J+ |
( {- \! j5 P% b& }+ r: Q
6 N, k/ _& C8 B# q/ K2 x1 f/ P2 b1 P5 ofunction RemoteControl_SimulationFinished() % H! I, q6 _- t' f+ g
{ 0 h9 T: W0 _/ E/ l9 O# ]6 f
WScript.Echo("Simulation Finished!"); |