Example of a JScript
7 V* s( D$ O, |0 Z* Q7 @var vbOKCancel = 1;
) e) j* `6 e" z! o: @8 Nvar vbCancel = 2;
. `) o/ b0 o0 V- X# S$ h. W% svar vbInformation = 64; 5 b2 o0 J- T6 n: P; I2 q
var Finished=false;
( O& f9 H. s8 Q8 N4 M; k
4 y' x* Y; `" `3 nvar WSHShell = new ActiveXObject("WScript.Shell");
+ ]/ Y. ?5 R7 J2 o( W ; I3 J' U: q( Y/ {# q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
r- J7 s& n+ E7 h 1 J3 F$ r* j8 g" e" e
simple.SetLicenseType("Runtime"); , b) I/ e6 a: S
- k) R6 J% \) w1 o; e* J$ Gtry & A$ J( G" G* p- L% S( n" D' k9 m, @
{ 4 w* x' F* z4 ~6 y, z
// Enter the path to a model file! - e, c. Q# {3 I) f* ^
simple.LoadModel("C:\\Models\\Test.spp");
7 K9 b5 Z' j2 \! `5 U" O( S}
& c5 L2 s! g, [: @catch (e)
+ ~% i/ J% e( N; k. w{
$ @/ U D; I' Z: ^ WScript.Echo("Could not load Model!");
) Q" G( R- w; L( f WScript.Quit(); 5 h4 S X$ B* M
}
1 s8 e$ N, R; l Q) H5 T6 @! |
. I, Y% d' T3 x) y9 n) P- p1 ctry
. `4 W( }" x E1 x0 z+ p/ s{ $ {" B8 T* u o8 E, _# [( N
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { - o" ^/ G5 `. J$ q
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
# Q- h6 Y5 X" \. _( a b! b! D1 K if (r == vbCancel) $ R5 N- o: i0 w: n8 o1 n+ T# a
{
8 l2 O4 L/ k! C3 w+ W simple.CloseModel();
# L% Q8 s( r+ C- k# J& A WScript.Quit();
% S, E; j/ w- b. X, T3 z }
, a( j% D) P5 M$ e1 T( c$ O/ \}
) r& w2 r6 u& @ + o E2 S# x+ m$ p
simple.StartSimulation(".Models.Frame.EventController");
* }; E9 U( \6 N/ P7 x( |
! E( S$ n# F) m. cif (simple.IsSimulationRunning()) ) G/ r# n& [" G0 ]
WScript.Echo("Simulation is running!");
$ d! g; ?. N, t
% d3 t* b f2 ~" i2 p// Wait until simulation is finished
" I" ^! \% o: q$ T, H4 D! zwhile (!Finished) WScript.Sleep(2000); - v3 {4 R# l7 ^) M( `
3 I- ^- e2 j9 u, h
simple.CloseModel(); 4 P7 b3 Y( V) `0 z4 p) V
simple.Quit();
: \5 p% F2 r1 Z1 UWScript.Quit();
: K( B! G' a; q: B: S& D/ H: r- E
6 g% d2 L/ S( N% I2 V: K
. U) y( E, }& d3 ?: A$ H. }- cfunction RemoteControl_SimulationFinished()
' l2 a- y; o" b9 C/ D9 h{
1 a6 o* G' {; I5 q* T# H( D WScript.Echo("Simulation Finished!"); |