Example of a JScript 9 x2 M8 C# Q5 x' a; {8 \) r
var vbOKCancel = 1;
; U2 x3 _, `, P# f% Lvar vbCancel = 2; : U- l1 a% t) c2 u4 ` o
var vbInformation = 64; / ]/ b1 B, o; o" m4 m
var Finished=false;
6 V5 c2 E5 K( W5 y2 m r7 S 2 `: z; p' ?# @. }' X8 x- M- o8 I0 l
var WSHShell = new ActiveXObject("WScript.Shell");
9 V, j9 g. a! A, y S ) g. \& z2 m; C2 v$ O6 W* _. c; Q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 G! p( ]' j$ S' O
+ t4 R) ?" I% ?; u
simple.SetLicenseType("Runtime"); " N! \$ c8 e' @$ ~
5 B1 c) @( T# }. O% l' D' qtry ( s# P" z3 I8 g0 _/ |) X
{
" ^: }4 l3 C* j // Enter the path to a model file!
7 X7 x( c9 r, A- m7 u! d simple.LoadModel("C:\\Models\\Test.spp"); 4 ^, U& |/ J) P& I% e9 n* @
}
4 p2 K! k# z" q# K4 {2 Vcatch (e)
" w, H+ _3 \2 p; |: N* G, a{ & e& ^/ c8 g5 V, o# j- r0 h2 N5 C
WScript.Echo("Could not load Model!");
+ B1 v% ?3 t/ f( z# m2 m2 q WScript.Quit(); * M' q' G' }! P2 _3 K& M
} : \6 N8 e4 N+ y
: M' t; [1 A$ J, ~2 e( \
try
0 I' Z& A7 z) @7 T{
( n" z9 z6 O& y1 H9 S( a simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { , l0 p" m; o. q, C
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 j* O% y$ w9 ~ W
if (r == vbCancel) 3 O6 L9 L$ e& T- A4 P1 E8 J( F
{
6 U3 l' Q( }" ^" b; r+ A6 g' P simple.CloseModel();
$ D% f1 @3 ]4 ?; h( M WScript.Quit(); - ]4 w% U8 P4 U+ |
} % L+ q$ b; o+ K! N4 B( \& {
} - ^7 B# d' I! C, s* _- m) x, H# D! n
! k* z/ C$ j: G* r! s' }: esimple.StartSimulation(".Models.Frame.EventController"); |8 d# \* {8 g! p7 \
4 @0 T0 H5 J$ Y( a3 Z( Bif (simple.IsSimulationRunning()) - `/ [, ^& G% K9 x* T
WScript.Echo("Simulation is running!"); 7 Q9 Z7 q5 n6 H, @) W) ?
5 J# v# b# b1 v// Wait until simulation is finished
" B, A4 s" R7 _: v$ awhile (!Finished) WScript.Sleep(2000);
9 ?( }8 y$ Y) ^3 C7 G( X # w, y& C6 J& L2 p/ G) D& L2 D
simple.CloseModel(); 2 U: ], L; `. z2 E$ r6 ]- ^/ x
simple.Quit();
# }4 Q2 _& Y8 |8 _- K8 b+ j9 lWScript.Quit();
: P2 b% A+ [6 `
2 p; E+ i8 |+ e3 H " `( _( w8 e- A" H2 f) ~6 h% V
function RemoteControl_SimulationFinished() ) P2 R; B2 Z8 ~- l: R. Q! K
{
% e0 N- K: X) b9 w WScript.Echo("Simulation Finished!"); |