Example of a JScript
. p' t/ m& Q+ X0 I! B( x4 ?var vbOKCancel = 1; 8 n8 T1 F! f' v* T
var vbCancel = 2;
* P% E; i5 T8 N6 Evar vbInformation = 64; 3 |& |1 K! o1 R. E: g6 Q' n( Q
var Finished=false;
2 g; o: Z5 V7 f! o8 I1 ^# ~ 0 h0 h. _- c7 F, E
var WSHShell = new ActiveXObject("WScript.Shell"); / F4 ~2 m! _# U! w6 W% D
" \ t- }+ i8 w8 _5 [3 rvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , {, B' d! D7 J5 V( J6 ^
3 _- _" F- t6 u! ?, V7 l# l# U5 T4 q9 E
simple.SetLicenseType("Runtime"); 9 X4 Y1 O# f% Y
) L$ H n. m$ ]. z0 l: b! }5 |0 y
try 8 f' w( B& P4 J: g% ?1 F
{
! o. Y- @9 D: f4 M2 G, Q5 V // Enter the path to a model file! ' E5 ~7 r* k" P8 _$ F( E" y
simple.LoadModel("C:\\Models\\Test.spp"); 7 f( g+ k% R( H. i9 n4 w% I. p+ o: J
} : P3 k$ K% [7 V& N7 |/ H6 y
catch (e)
* [4 u' Y( h: O" H" V$ v2 N{ # Y( C# a/ h8 l/ N( S) O
WScript.Echo("Could not load Model!"); # Q& F O5 K. T3 C4 V4 d3 B4 u4 p1 r
WScript.Quit();
4 r! |3 Z# G( J2 ?0 Q; S# G}
; E9 V. m, F% `/ D+ u& t7 |
; }0 @ n; `& k2 j. m- wtry
2 S2 i: Z( C! P+ d% d ?{
0 ~) r3 s" E7 O7 f( E* z simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# O) Y0 y- j$ C' g' t0 i r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& N7 D% G. P8 q if (r == vbCancel) : H5 ~4 Z2 P" ?! k
{
/ P6 ^( ~! Y+ A6 h# }7 \ simple.CloseModel(); , h% n( D% G$ a- _& v" Q, }
WScript.Quit();
& t, \; O+ o) l9 M% m1 e9 t* P: F } 6 E6 r0 @5 K: `7 G
} ; W% H2 j. \; g- `# |$ p5 E! ^
2 O2 I# s& J% Z8 B; Y$ p
simple.StartSimulation(".Models.Frame.EventController"); . u8 b$ L9 `0 |/ ]7 \
L& A' F/ E6 t' u1 z% p4 N
if (simple.IsSimulationRunning())
2 v( H4 x/ d6 | WScript.Echo("Simulation is running!"); # P" H* ?. P# @, X7 i7 b% i
7 ^ V8 i& Z& I% x3 M- E8 h" R
// Wait until simulation is finished - O+ ~) `, o( \+ G9 [0 _
while (!Finished) WScript.Sleep(2000);
& r0 s k$ d6 @& ?
5 ?" l5 Z2 Q# A4 P/ Isimple.CloseModel(); - b5 b) x7 l; M2 y2 g4 V# `1 R& y
simple.Quit(); # c6 ^' ~6 m! u3 V2 T
WScript.Quit();
6 X F: V( M3 B7 v$ W
+ ?8 w& Q. s* A O' V) e+ T1 g! E! X+ y' [
function RemoteControl_SimulationFinished()
/ Y3 U2 d `4 c2 F2 A' K; d{
4 r U% E" U4 R9 g WScript.Echo("Simulation Finished!"); |