Example of a JScript
/ C# Y- T9 u3 H8 n' \1 Zvar vbOKCancel = 1; - v0 @6 [6 e* q; A" z/ M( }1 e' `% O
var vbCancel = 2;
" v! T/ J1 b9 n0 p+ G) Z- D2 Z+ `var vbInformation = 64; ; c' j* [+ [$ y- e; B; N
var Finished=false; 4 {/ W& Y+ e9 _
! T/ `0 J C2 c
var WSHShell = new ActiveXObject("WScript.Shell"); # K4 \' n7 o \8 S$ S3 a
6 A6 w( |% _ g. P! a
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
4 a' k0 Q" e, z( r
, P: T( M& {# v* m& P# F8 E; |simple.SetLicenseType("Runtime"); 6 }2 m/ ^5 C9 Z6 x4 {+ C \5 s g
9 \& r: y1 u2 ^0 R5 j0 @' z. ~( N
try
/ }/ h# H2 ^4 b{ 4 y. Y& T/ e( N2 L% _
// Enter the path to a model file! ; I. `6 Q# d# I2 p6 e$ B
simple.LoadModel("C:\\Models\\Test.spp");
$ g3 \* T, e" T) n& L8 v} g5 D6 A4 i. F: q
catch (e) 3 H& _$ M& l9 S
{
" e, [7 x% V7 t9 h, z) q$ v WScript.Echo("Could not load Model!"); # R6 |6 |& U' h, ^. D' A
WScript.Quit();
s9 n8 D8 x; W* S} , r9 Q# x" C: F! t
9 V7 ?: L, u$ f1 G. u3 Vtry
' T$ t* q l6 C! M: s b{
& Q4 M. e" E; B3 E! x simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
4 ?1 l" c8 n6 H& |6 d r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 8 [) M) r4 d- J, H
if (r == vbCancel) 4 t2 I5 C5 U( g5 ?% D# U a3 u; J$ v9 L
{
0 I$ j1 y9 D) C/ S- v simple.CloseModel();
. m+ O+ r1 j1 i0 G WScript.Quit();
" f k! n3 e5 g9 M, w+ B- ~% l. v }
( F6 ?3 s, W+ G O) F# {/ G; E}
7 X/ V4 T* I! U ; G' G4 O' T9 u) z6 M6 a! |
simple.StartSimulation(".Models.Frame.EventController"); # B5 a4 o9 w7 }- H
1 s5 ^* Y- ]3 n) G" H/ ]: Y+ c% W1 a
if (simple.IsSimulationRunning())
, v! O1 l0 ^ S% h4 Q# A* G WScript.Echo("Simulation is running!"); 0 B% \6 g% Z4 U* P
) p# g. ~7 S( G+ p// Wait until simulation is finished
; @, j D$ Z" y( h) c3 K6 v2 cwhile (!Finished) WScript.Sleep(2000); 6 F/ F+ t( x; Y, ]
8 T1 V( a" |2 a; }# j+ D- ~ s
simple.CloseModel(); 8 u5 w6 ]- k1 l* U
simple.Quit(); - ^. ?! i, B; R6 M( v9 a( g
WScript.Quit();
- S0 {- A. r1 g
' K6 n7 d. i* V: v" u2 m! e7 [
9 ~4 A+ C7 P w; ~4 n4 ofunction RemoteControl_SimulationFinished() & N; N' A+ ~0 J& ^. K- C
{
; m0 B0 h" f5 ]2 T6 G WScript.Echo("Simulation Finished!"); |