Example of a JScript
# R8 N) R' k+ N+ xvar vbOKCancel = 1;
) e# O# D7 V; d# H2 J# X* Q, q3 ]) q2 ?var vbCancel = 2; % P$ Z0 G. N' x+ v% U' ?8 L# b& k" ]
var vbInformation = 64;
8 O3 `8 Z8 j# Q, g$ `$ U9 l2 pvar Finished=false; , c2 i `$ \, v
( I5 y9 e9 K, p* w( g& b
var WSHShell = new ActiveXObject("WScript.Shell"); - [0 F# E7 w$ v$ h% Y
I& c) R5 v. l% u4 Zvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
% z. a5 `: J; k( p& H + q0 [6 G% _. f) c& U! ^' C
simple.SetLicenseType("Runtime"); ; w( a9 ?$ j D9 Y( O K1 o- j
5 g6 E. A. ]) P8 Q( Z2 ptry 4 W. h& I* l# r! M: N( H; E, `
{ V$ P( u6 Q$ L; v7 R) ]
// Enter the path to a model file! 0 C5 l/ k) l9 m* z) b
simple.LoadModel("C:\\Models\\Test.spp");
% R; S" S& ~' b+ ^3 g}
3 `. K5 i. c# f; f0 r6 Z; O/ dcatch (e)
4 [! ?7 Y7 e# [; Z{ 6 [- a7 l3 N! w& F; a
WScript.Echo("Could not load Model!");
8 H- ^! K0 B+ ~ WScript.Quit();
) T. W6 t5 ]; _/ ~- |% V}
. L. R. O7 |: n D$ u2 \ ' [" M$ {3 e- M
try 3 |$ u: h7 F9 `, k3 o' Q+ K* {" p' G
{ & L$ J) U1 u- Y$ c! h3 Q; h, H9 ]
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ) _: c* J+ p9 c7 F! Q
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' N* J5 w/ o5 h! Q
if (r == vbCancel) ; |* T5 E8 y# F8 I5 W+ J
{ 9 `: E" q! x7 S+ w& U' m Q
simple.CloseModel();
) u, ~0 U% Z$ l WScript.Quit();
9 C% [5 z$ ]- \3 ] a( w# q) S }
# p- a5 F8 c+ C6 D}
~2 S, U7 c) S- Z
# F: d2 J- J: U" l9 j* gsimple.StartSimulation(".Models.Frame.EventController"); + ]* O( p7 X, @" m7 z
. g8 s$ ]! y3 A8 c1 ~' k5 _3 d
if (simple.IsSimulationRunning())
0 m, ?) r( O" ^! f- h WScript.Echo("Simulation is running!"); - ~8 h9 V& ]% A: S4 y2 {
, _4 P8 u! U- w
// Wait until simulation is finished + a* b4 ?7 C) R- O: I2 E9 F# ?
while (!Finished) WScript.Sleep(2000);
# Z1 Y( y) v! H: A$ U- ~ 5 Z$ t* `4 [9 A2 l8 m
simple.CloseModel();
* z2 }: z& Q7 [2 Y$ j6 c- lsimple.Quit(); ' c8 t+ }! F2 r# W) z
WScript.Quit();
9 D/ e" r; U% Q
) F" ^, b/ I" f : H6 J/ M+ Z: X$ U5 M
function RemoteControl_SimulationFinished() " w7 j+ V( t! F. x
{ # R: K* V4 G' x1 `2 h
WScript.Echo("Simulation Finished!"); |