Example of a JScript 9 |9 f0 n2 ^" ^
var vbOKCancel = 1; % Q" O/ D" [: L8 R3 J
var vbCancel = 2;
% l! G8 j4 H) p i5 s# mvar vbInformation = 64; , Z+ q$ f) ^, f7 P3 b+ ?# c
var Finished=false; ' |0 r/ d! w/ t. n c* X
/ @. \4 g! Y# [8 ]
var WSHShell = new ActiveXObject("WScript.Shell");
5 D$ w9 e; A6 C' v6 r/ H5 l! [ 6 D+ k: A. m" h1 `& U8 `
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
3 a) u0 e% Z! z3 c! I9 r1 K
- W5 c/ o+ b; m5 [9 _3 Esimple.SetLicenseType("Runtime"); $ n4 T2 }8 m) A& |5 j' r
5 |8 D. t s$ a* u( _; r: N
try + J' ?' g) ~5 {2 A" }; K
{
5 ^# c; ^. M& ?3 u( b // Enter the path to a model file! - K* {0 F2 n: d+ v. Y. K+ N9 D% g
simple.LoadModel("C:\\Models\\Test.spp"); 9 ]9 {3 T1 m0 a+ x
} / [9 o" |2 ^( f( T- H) b$ a
catch (e)
/ i0 D' t, p4 d4 Q4 q3 b, ]{ 0 }* p! K& C8 H8 F! G) D. K$ {
WScript.Echo("Could not load Model!"); # [% }7 s) d! `3 R
WScript.Quit();
/ D$ N0 w7 V# ?/ l* r} ; P8 y' ~& p7 ]9 m; w
7 a2 f* e# f3 K$ A1 Otry
, w4 h, g: `* c. x d6 [" [{ 2 D, @% d" `% ]9 O# `3 S
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
0 h/ z: s% t" r7 T; a$ o, j r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
: m J% Y5 g2 _) N# P \7 d3 D if (r == vbCancel)
# ?7 P6 W2 d7 T7 ^7 u { 6 _2 e7 W8 R) T
simple.CloseModel(); ( r- B" \$ P0 K' ?
WScript.Quit();
/ s+ x; O# u Q n5 w% ` } 3 [; \5 q- i& m- I% M
} ' Q( `! Y0 H" [7 I* u( `# f
# y7 e" x7 o1 p9 S4 ~
simple.StartSimulation(".Models.Frame.EventController"); 3 T( q- _8 }& W, v2 x
8 ]% i O. b7 ^/ _7 Eif (simple.IsSimulationRunning())
7 K6 s1 n7 `9 v7 z7 { WScript.Echo("Simulation is running!");
0 O( g J+ U7 P; L" `; S % ~7 ] `' f( m) S# s: y
// Wait until simulation is finished
: ` h* A g# {8 Pwhile (!Finished) WScript.Sleep(2000); 3 \0 x% n" q% m6 F# W
0 c6 [% {& s; D+ A" }8 N
simple.CloseModel();
7 a' b2 Q* Q0 `+ \simple.Quit();
' B- t& a( O' e4 xWScript.Quit();
7 P/ y9 B7 _$ M; e1 W
. Y# S1 {/ r$ O/ y# p% C! ~3 `% J 7 y) |' t- b% c6 ` i
function RemoteControl_SimulationFinished() 8 a# o \% p) y" K' V
{ 7 ]( c: D4 r; r# t; Y3 \& S
WScript.Echo("Simulation Finished!"); |