Example of a JScript
) P2 W- W# ~9 L! Z, ?' i! _2 Avar vbOKCancel = 1;
+ O' z6 k5 t4 O* avar vbCancel = 2;
7 X; r& {6 P% L/ nvar vbInformation = 64; ' f/ e9 @ A( R: V
var Finished=false;
8 W+ y" y, ~% ^7 f$ [ & B8 Z% H! j3 G9 M# E
var WSHShell = new ActiveXObject("WScript.Shell"); # E& X; q3 u+ _+ A& w( k5 N
2 Q, r4 J) \$ z
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
7 e# {! b, R4 b, J4 M7 K' o
! y9 z/ {( H, X( a2 H6 o2 vsimple.SetLicenseType("Runtime"); 7 g4 P+ V* ]2 @$ U2 m9 _
: N! P8 f5 V, T4 ?8 Y. y& s
try ' [3 [7 Q w, t. J8 j( A
{
7 U$ l8 ]5 T0 ^1 w7 H // Enter the path to a model file!
. o7 r% m8 b/ m( t5 P& H& d4 i s simple.LoadModel("C:\\Models\\Test.spp");
5 |3 P$ G1 [ i3 G8 u3 |% E4 Y# D% H} 6 M X5 Z) t2 {, ]' h
catch (e)
: h4 L, O; K% W' q0 W, r \{
% g; U; L+ z. P6 w WScript.Echo("Could not load Model!"); / j# ~4 D' ?/ i2 N3 g
WScript.Quit();
5 m7 a/ }# S& c* c( |} 4 j( }! `& e: V: o0 {
) A4 a; c. Q7 A3 Y
try
0 n/ H: M- K$ y, k- o" M{
8 w4 r) D" W m& H+ i7 c S R+ h simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + o8 a5 U- _ G6 e, j" C/ p: N) K
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
! R5 m% K- Y0 D0 V if (r == vbCancel) 2 ?( ^1 |! d* V& O
{ 6 F% U) y2 n6 d3 v
simple.CloseModel();
7 L$ i# y3 q. F4 p WScript.Quit(); - D" q/ x) V R4 M) g* }. X
}
/ S% T; z, |% O$ m2 b' h6 g4 l}
. S! R( n2 q; b- O' s
' K9 e2 k/ `% V* v- O8 ysimple.StartSimulation(".Models.Frame.EventController");
( n2 b4 O( j6 t * m9 x) W) Q/ W& V: C
if (simple.IsSimulationRunning()) 6 S7 o4 }$ }. p% h) Y7 O9 X
WScript.Echo("Simulation is running!");
1 }9 ~, q' a4 j/ \7 R
, U; ?! P3 F% d5 |/ b// Wait until simulation is finished " I+ p9 s3 [. r6 s
while (!Finished) WScript.Sleep(2000); - X: s# S8 g3 t9 Y" u8 K: d- P
% m1 S9 k4 H4 J
simple.CloseModel(); 5 l) j+ P; m: x2 t9 I
simple.Quit();
$ a) p/ \ \. E5 qWScript.Quit(); " @: d, X# O, v6 U
7 P& H7 N2 J. w; d' O6 b# I/ \
) t Z4 [5 H5 Y+ m5 Rfunction RemoteControl_SimulationFinished() \) _3 t3 c# z5 j' E
{
, {3 B. V8 o) q Y WScript.Echo("Simulation Finished!"); |