Example of a JScript
* M) ]# N) s" a7 P# Avar vbOKCancel = 1; * x+ e' G# `- \$ o7 s% A4 ]
var vbCancel = 2;
1 a5 R: {( W0 r& o6 dvar vbInformation = 64;
4 S' O/ d& e0 \& ]/ ?. yvar Finished=false; % g, c7 f( N Y2 Y1 h* c& [
) b" g0 n" P% B9 h$ f6 ivar WSHShell = new ActiveXObject("WScript.Shell");
0 j0 q& Q7 ?4 }4 ~9 Q # Q) c L, O+ h. k7 {
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 X& Z L. U/ U; W3 V& c* G
% B; N5 R& l2 m5 N ?simple.SetLicenseType("Runtime"); & [! d: S7 C- X5 d* [
; j% c. G2 ?* ctry % O# P' T3 u% Z9 ?' B
{
8 W) {4 m2 }7 }; g9 h // Enter the path to a model file! 0 P+ }' a0 ]) q5 F- a+ l0 G
simple.LoadModel("C:\\Models\\Test.spp"); ; B/ Y+ B( m8 n
} : g' C: C% u/ a" V5 M: o# c
catch (e)
( c4 ]7 [2 @/ @{ " i% }% y) o% ~2 c) b
WScript.Echo("Could not load Model!");
+ a- V6 o. q3 ~ WScript.Quit(); , K5 J+ P# d% v% G4 p5 _
} & i6 ~' w; l" |
) u1 C: f) \" E4 _
try
4 s( t, h* u& ^{ 5 ^/ j/ R! t7 G7 ^) k
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # E+ r: w, s" [6 l
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); , H( E" W% r# g& b
if (r == vbCancel)
8 g4 k/ P5 |+ U1 P! U* a# v { + x+ R/ ~# e5 Q3 O
simple.CloseModel(); r! v( E3 v; I' Y3 f, I8 L% S
WScript.Quit(); * A( Y( K' i9 Q L) f
}
4 d/ {- U& g1 e- a; L. G' g* t' u/ P} + B* l( z) Y# R% X0 J1 y' s
% c' l. A) R# ^
simple.StartSimulation(".Models.Frame.EventController"); ; o# i+ l9 M+ T4 H9 p2 l- D+ X
5 q, }- z& h5 B; j
if (simple.IsSimulationRunning())
+ u) y- _8 w' v) a9 U- |; c WScript.Echo("Simulation is running!");
1 K$ l5 h: E" H7 R% e. ^+ @$ q: H5 V - o/ X5 G* h* E* R( I, D8 C0 Y% g
// Wait until simulation is finished
7 i8 r, c3 {4 G& @while (!Finished) WScript.Sleep(2000); 7 N$ R& ~3 ?# @" A: {. k
; s. d1 f ^- D6 W! d4 f) I# o
simple.CloseModel();
& H- P% e: b0 n0 E {5 @* U0 Y* zsimple.Quit(); % `3 }; h" |2 ^# [% T: F2 U' a
WScript.Quit(); " l7 }1 ^' C* ]* R# t: b
! R3 o, q+ W A# c8 U$ K5 @# H) ?
# o2 E' g, E5 ~ cfunction RemoteControl_SimulationFinished() 5 ^6 p V. T j1 z1 [& e
{
" U, g5 O& _5 p1 l WScript.Echo("Simulation Finished!"); |