Example of a JScript
; h" _! Y1 G% z2 p% Hvar vbOKCancel = 1; & t7 N# i+ o2 e% D' c4 N; W0 E
var vbCancel = 2;
6 U* v& {3 f+ c8 W( q* H. r# `. ^. lvar vbInformation = 64;
' G$ M) Y0 ?- |var Finished=false; % E, I$ J/ u% O8 P. f% }( G) _
) _! t. x# {+ s7 P0 vvar WSHShell = new ActiveXObject("WScript.Shell"); + T# \& Y. e' R; y, C8 j, Z7 \5 j
: D; S' i7 {8 @2 Q# I. j8 X: jvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); / H5 d" ~) w: G. F2 O' R) l
% o% [) }7 e. @1 j& H
simple.SetLicenseType("Runtime"); 1 D' G0 l7 N( ^/ h ~
z& `, i t7 [; x8 @try 6 h4 U7 v# @5 M' R/ ~- G/ a) Q9 ^/ J+ }
{
) ~ o4 {' u4 Y, L2 h // Enter the path to a model file! 8 H, d0 x0 V6 y5 Q( r3 S
simple.LoadModel("C:\\Models\\Test.spp"); 3 e& i# S; R3 v5 U8 M C
}
' V! M0 m1 k( u( p2 f( rcatch (e)
, J" d _4 {& m e7 G8 `{
; d# ^. J e, m+ X8 Y WScript.Echo("Could not load Model!");
* _' A$ W3 O" B% r4 Z1 o. U9 H: i3 S WScript.Quit(); 2 O7 j- b1 D* ?) j) e" e
}
( c! O% \& Z6 B. V, W8 B
$ _/ C1 J; a/ C" S# P7 i6 ttry
& O5 m( o$ W V3 u{ 4 r4 ~/ x; N$ y1 F
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
) S7 O2 U5 T! R( [) l- q* b+ k) J# { r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 0 L! w! S9 D* u; t( I! `
if (r == vbCancel)
% H$ `+ L. F$ k% S { * M$ _. E2 S; F/ N; ?) X
simple.CloseModel(); # C- \; F% V+ ^, ~8 v4 Q
WScript.Quit();
0 B7 a9 M+ n4 a j4 U: C! _ }
7 @! s) G& R, A. {$ p7 B8 F1 A} V+ W1 ^- [) ]% [9 g% f
2 h9 Y5 y1 U) m
simple.StartSimulation(".Models.Frame.EventController");
$ T8 s2 Q* i# c* g* R - W# O2 w" ?. b( l
if (simple.IsSimulationRunning()) 3 S: ^* f3 ^$ j# P0 }
WScript.Echo("Simulation is running!");
+ {# `7 U( t9 c. w
! t3 ?# _( I9 ]// Wait until simulation is finished 6 H2 e8 U9 R, d; L: ?9 U
while (!Finished) WScript.Sleep(2000); 4 F) u0 s# w3 h
! G9 M' Z; N- ?7 k" [' d+ d$ Isimple.CloseModel(); / T. i+ H9 y4 B5 [, `. S6 y2 u
simple.Quit(); ! M: Y9 \6 _# A' D0 }
WScript.Quit(); 2 k' ?6 x& G' Y* g! X& t* \) S
8 O1 d" ?( K+ c7 i3 Q5 Q4 R
( t5 ~- l1 ]4 ]+ c& `function RemoteControl_SimulationFinished() " \* n* R1 E' d
{
" U* U% q; x s4 {- i4 R- w" }' ~ WScript.Echo("Simulation Finished!"); |