Example of a JScript
3 ^ j% Y. S, f$ Pvar vbOKCancel = 1;
1 S1 L6 T* M* Q, Nvar vbCancel = 2;
+ B4 G: Q! t5 N- _* I" Svar vbInformation = 64;
+ [% |" h: ~' ovar Finished=false;
$ u+ N# F; M. H6 A ; O% p+ Y: ~% T" |8 V
var WSHShell = new ActiveXObject("WScript.Shell"); O7 g. L8 c& A$ P9 b; i
, t( C+ Y2 B8 f0 T" k* N* i" Wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
& O' d' u) \6 s x2 Q$ | " i, B- v, J; ]0 T7 }& q& [
simple.SetLicenseType("Runtime"); 8 ]# @3 }1 u. g! i. a/ x; r. F% c
0 b6 S- \$ D$ j% Z5 O2 [: Ltry 4 i" O3 r' f/ J) F( u( [% k) i4 [
{ - |6 o3 |; g" z. Q
// Enter the path to a model file!
* z# K" N: h, v7 X3 e simple.LoadModel("C:\\Models\\Test.spp"); & k( T7 ^9 {) ?( k$ A7 d
} " H4 W7 _0 ]2 H
catch (e)
; |# b C9 w' o5 l% o{
5 ]7 h, \& A. _- [# t WScript.Echo("Could not load Model!");
$ d/ q. j) y6 g* H. T1 `* h WScript.Quit(); 4 ~0 ?/ V D2 |* l. ]" j5 h
}
. \: L9 j$ N- F9 v& h- O
7 f5 J2 i. Q( G y; V8 }' ftry ) A( T6 I' b8 d; Q
{
7 J8 N' u' _# c# w/ _5 L2 p simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
* W2 O, F* Q7 j r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
, T7 |$ p% J+ p; D8 H if (r == vbCancel) & H$ G F' V1 O8 P0 h
{ / v( t5 u" v% ^5 w9 ?3 u% |
simple.CloseModel(); 7 {. T4 R" Q) U* C% { _8 T
WScript.Quit();
* |' c# {; ^* M& w* H" T9 Q } ' b3 Z" S: {5 I( ]- k" x
}
* e1 q) l7 ?5 T' f) l
, e$ j; p( i6 xsimple.StartSimulation(".Models.Frame.EventController"); 3 V* z }( }5 N
* J5 d4 g; r/ R) `4 uif (simple.IsSimulationRunning())
6 \+ e, k& r6 t% H0 S# C s WScript.Echo("Simulation is running!"); ; Q; y' v7 B2 j6 L# B, u3 G B( V
" o; p% i& ~" h- c4 i' s
// Wait until simulation is finished 6 X% e1 g' F2 I- T; u" ]
while (!Finished) WScript.Sleep(2000);
* T/ L8 `- w- K/ i " `% i: x4 r, D0 c
simple.CloseModel(); % s0 E3 `2 v- \8 D
simple.Quit();
; h% G9 t2 x% K S! IWScript.Quit();
/ T- S* r; g$ l, k! w! ]" k
# n3 r2 h: J! e: U7 ], z + t1 m3 z6 q$ u% N- w X7 ?
function RemoteControl_SimulationFinished()
{, m* m/ c+ y. _( J{ 1 g* V$ k1 p1 d: U2 x5 H5 F
WScript.Echo("Simulation Finished!"); |