Example of a JScript - R9 D f2 q2 M T/ I" a
var vbOKCancel = 1;
0 I- z! O; Q" B3 Jvar vbCancel = 2;
# ?7 G$ w) L2 p! \( Lvar vbInformation = 64;
; s9 ~% G/ R3 B0 ~& Dvar Finished=false;
8 S! T3 y6 P" q ' _9 C: l) v; T) t- M
var WSHShell = new ActiveXObject("WScript.Shell"); # v6 N3 u G0 [7 {
, q& M& p6 b- y/ q- r4 svar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ) I- ^8 [9 N' Q$ M! W u
9 `* i+ s! L( s4 v2 ^simple.SetLicenseType("Runtime"); , ?' k: b5 m' O a _
0 v$ E6 L$ \; t' _' Y) }: e
try ' p, a9 w( ~0 ^; L
{ ( e' @4 p8 i P! P+ a
// Enter the path to a model file!
$ g& I V4 a5 r D8 w# H simple.LoadModel("C:\\Models\\Test.spp"); 6 V7 O) @' H8 n0 q" W8 M
}
; o0 E5 ~) s2 ocatch (e)
* O$ z Y; U( Q* s* W% e1 m# Y4 A{ / l' D! X6 y: X
WScript.Echo("Could not load Model!");
+ |* e0 G- D, k2 Z WScript.Quit(); 6 o6 P) h% L# B& p% P* x& o' A
} 1 W% i, e( ~5 O+ t4 X9 i' Q
/ o3 K- U' V8 n; `7 i$ q% f8 O6 Ytry
! ]) A( K8 E3 |; {{
" M! n; @- j8 O: b simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ' s# j+ G. H8 A
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 7 q7 s9 @- A& t. U- I
if (r == vbCancel)
7 N1 d7 I& L. h0 a1 @ {
1 R4 V& {$ G2 t; U) l simple.CloseModel(); . P. [* [+ c/ |# Y/ }' M
WScript.Quit(); ! C( U1 x; o5 ~9 @0 B, U0 q* A$ _8 M
}
% h J4 F3 Z% S8 w( _} " _, N( v" U5 ^' m
& U: g S Q! `$ @simple.StartSimulation(".Models.Frame.EventController");
1 W% R( V j& _" x8 a) G / e) k1 M, U/ }5 t7 v, |. m. \
if (simple.IsSimulationRunning()) $ S/ {# o) Q! @- o# G1 \ }
WScript.Echo("Simulation is running!");
; ]8 ^' p% ^2 T- C9 o% l W E 6 W: S0 }4 ~2 u6 k, i/ E; S
// Wait until simulation is finished 1 ~! ]2 N7 n' D+ x
while (!Finished) WScript.Sleep(2000);
) t7 P3 u# Q4 \' `. O6 M + \ p: b% M* a1 C1 ~: B' [
simple.CloseModel(); # c! ^+ }$ R1 e
simple.Quit();
* x, f) r+ P) E7 h; _WScript.Quit();
% ~8 w6 y# P1 ]) e R9 N 6 `6 l* m$ g) g
1 F$ E% Y# Y" X9 r9 H" Hfunction RemoteControl_SimulationFinished() 1 f: U4 A% m8 h% |
{ " s' @" F" A' ~& m( ]! i v3 \! T
WScript.Echo("Simulation Finished!"); |