Example of a JScript
2 q1 b& s% ~0 p5 ^var vbOKCancel = 1;
, N( o4 [+ s s% ?. i# Uvar vbCancel = 2; 3 `' }' F8 V3 s
var vbInformation = 64;
+ o: [2 E# V4 ^: w; S+ pvar Finished=false;
: l \9 y$ r* B' @5 P/ q! U ) D! Z6 z3 m* N: O7 w H
var WSHShell = new ActiveXObject("WScript.Shell");
2 O; H5 c2 w( D) v+ g7 ]
% |$ _, c- h3 Xvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
2 ~# B2 W6 }5 a u9 w3 a ' `: y) j' i; n0 i0 w7 D$ d
simple.SetLicenseType("Runtime"); 4 H$ w6 b+ w0 r1 N: ]4 {
- S' o" L$ q' c
try
; ^7 ?7 {) I4 f+ }4 O2 r{
g8 Z9 A# d5 ?, l3 N" U% @$ q# r // Enter the path to a model file!
: Z* x- G! F! Y- x simple.LoadModel("C:\\Models\\Test.spp"); $ r& L+ i! [4 d8 P9 o& i+ {
}
- g. E! I! Y, y) d5 wcatch (e)
, U) }% L0 w0 I: y! T- T{
8 [5 m5 a. S' T2 }! M WScript.Echo("Could not load Model!");
o5 M4 ]! ?8 F5 l. y! v# F WScript.Quit();
' l8 ^3 k2 d$ k- B8 X}
" y3 j! f- ^6 K- f6 D7 o! u2 S
5 M, E% f0 x v9 j1 j# M' Ctry " e2 G/ {' N& h0 }# @1 q
{ # \3 y0 q2 ], H `7 L( M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 9 R* G0 e, y! t/ f+ `
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
; Z) _% h7 F0 [1 t K5 K if (r == vbCancel)
1 g" o1 D" a* [, n- F { % l1 e8 [* m: P7 D: E) ^
simple.CloseModel();
# A6 G ]' r# Y0 O1 y% T WScript.Quit();
0 V% q, D9 y+ p2 g6 H } % [! p* {- }4 Y
} 3 q/ \6 \, S4 [1 J/ j
9 e6 l ]6 w* k; ~1 e( y: O0 l
simple.StartSimulation(".Models.Frame.EventController"); & w9 W$ i0 e; @8 S
, [) [9 E$ N/ u; |: G. X3 _* u
if (simple.IsSimulationRunning())
$ d; X3 p0 s4 f# W WScript.Echo("Simulation is running!");
3 ~# o p; D/ |1 Y7 @: v + B9 B0 c& m! B: j
// Wait until simulation is finished
) ]. |' Y! Y9 S8 ^" Fwhile (!Finished) WScript.Sleep(2000);
' }8 m; c" ~- z0 \+ C # ]' Y1 [, I2 {, c: A
simple.CloseModel();
) ~2 R) X+ x8 F$ n' Vsimple.Quit(); j8 X0 C1 R& P, v
WScript.Quit(); 5 { P: ^3 T; D- l
1 z' Z, b: y' W+ T
0 C0 m9 i2 v# d& W3 E
function RemoteControl_SimulationFinished() 9 `, J4 Y$ N- X3 i& o1 Z
{ 2 a6 K4 N4 O0 ^6 n) R
WScript.Echo("Simulation Finished!"); |