Example of a JScript
R. w _5 M; W3 ^var vbOKCancel = 1;
; a# l* S$ R( A; U" U" c% y; w) Bvar vbCancel = 2;
& b/ q" G5 ?! evar vbInformation = 64;
" G$ d' N" V( e% C* dvar Finished=false;
! q% g4 F/ K0 ]5 _# _ 9 |5 T5 M) J& T2 |
var WSHShell = new ActiveXObject("WScript.Shell"); ' ]8 p; j: [* C; A3 J
; f7 t# V+ e* X+ u1 Z
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 0 j* ]' b9 p+ l3 {0 U% C B/ o$ e
: s! c- B! P9 ^; ]% psimple.SetLicenseType("Runtime"); 6 ?% h; ~: l" F s& d
/ S$ e- \. h/ f5 e$ M7 M
try 7 A) `- N) @" f% P) f- p
{ 9 J$ P0 B9 r$ T8 s+ T" z
// Enter the path to a model file!
# ]7 A2 D. o4 l4 b* S: _ simple.LoadModel("C:\\Models\\Test.spp"); * }: f7 b) x+ T2 p9 t
} ) U. ~) h3 e1 I& G/ ^$ q/ F l* N( l
catch (e) 7 L7 Z7 Z h, |1 a! R: Z# X) W. v
{
3 D [ J/ d Q1 ` WScript.Echo("Could not load Model!"); % S3 b# B1 Z' w
WScript.Quit(); 3 J% p! z* l4 l; T& b
}
: G8 H4 i4 f/ l. w& {) N4 i! k1 s 6 I" c, T( N- s; u2 W
try 4 r1 B( q+ N5 e0 Q; n
{
8 f" n4 P6 J3 i simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
0 ^# K6 J" N/ U8 g r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 L. I* Q, h. p0 p; S9 [: W' Z# |8 K
if (r == vbCancel)
( k3 m! J3 G8 I' ]; n, U) L( k {
8 O3 P8 n O0 A+ e simple.CloseModel();
- K3 z; ~ n( a# F% R8 `. y' U WScript.Quit();
) _( ~, _ p1 \ } " i# h* b, P1 ?' [+ o8 h$ j) Q
}
% B9 w+ {- u7 [
n) Z# i1 h$ I' i. Q4 bsimple.StartSimulation(".Models.Frame.EventController");
9 X8 b1 |) z# u/ L! J; b; M
2 I0 w0 F s8 L1 K/ F* D. I) i }if (simple.IsSimulationRunning())
$ r0 _: V, Y1 g) q" |4 v4 o$ u WScript.Echo("Simulation is running!"); ' g4 B( l% ^7 q- J% m
" @$ y# R' Q7 e6 |/ W// Wait until simulation is finished
' [/ y ]) u9 R5 c+ }7 l4 O$ Z, f8 Qwhile (!Finished) WScript.Sleep(2000); 9 w4 V, ^0 W5 ^: Y$ d$ g" u
" p' Z4 e, Z, N, k. d
simple.CloseModel();
$ ? t- i r% K/ `" `; ]simple.Quit();
/ o) s( r$ d7 [+ }- j. t, UWScript.Quit();
) [+ L/ J! l- ~$ k& ]+ k7 J2 j
! i6 |+ F% Y# E# k# t2 _
1 G3 Z/ z1 [2 V) F2 J' efunction RemoteControl_SimulationFinished() / ^2 s0 `+ ?) x" ?9 @
{
! V4 p1 h- l+ k5 E9 h6 h WScript.Echo("Simulation Finished!"); |