Example of a JScript
. V+ f% H& T" d- x- U; v5 \var vbOKCancel = 1; % z. ^6 V- V& M5 u+ s, `
var vbCancel = 2;
2 ?: r2 w1 h+ m! {. c& k7 J1 hvar vbInformation = 64;
( \3 f" }0 d- @3 D/ }0 \3 Q; T8 Avar Finished=false; & M6 x9 S4 Y! k& e' k1 o$ b) |
1 S, H* y/ i7 I% g$ M% O3 N
var WSHShell = new ActiveXObject("WScript.Shell");
* E- _6 b+ ?8 Z ; w) {# P* y5 L* N9 `
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); & n) A7 P; W$ D) J# }/ K
3 s' R3 ?3 |- M f+ v# M2 D
simple.SetLicenseType("Runtime");
7 H! I" B9 ]' R V" n6 ]+ ~/ G $ [4 e" b% {; P6 I) w W
try 7 d8 Z @ R1 N
{
C0 K8 n1 D5 G/ G/ T( ~4 B3 Z // Enter the path to a model file! + i4 Y3 q! ^$ t, E7 P# G) ^* t
simple.LoadModel("C:\\Models\\Test.spp");
; J8 N& y- _' f}
& ` Q& R2 h, q/ [- `2 p7 M1 \8 kcatch (e)
2 }( ~ s2 F' u1 P- K$ M{
% [/ z1 x& _, F WScript.Echo("Could not load Model!");
+ {0 R" K& B) Q, o: s WScript.Quit(); " {- i3 M6 Q; y. A2 Z
}
5 t. \4 m( o; p3 V* o% G0 w * P* H# a5 V8 \$ F' i t
try 0 I- A6 o+ S# r! D" O( ~9 R! R
{ i! W4 j3 k2 K
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
1 m. ]! D7 [: c1 \( R( _% n r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
* b3 m( a# M- Q if (r == vbCancel) 6 _" {0 h1 F7 E/ G
{ ! k% C- Z' r4 j: }( A' t
simple.CloseModel(); % k8 r6 e, K* ?) ~. F: a
WScript.Quit(); C$ i4 g, C( i1 L: y
}
2 y& _8 \4 Y1 C2 `0 A& k}
' e' q, o& E! S6 c, h $ w4 M2 v1 Q: V9 M! h
simple.StartSimulation(".Models.Frame.EventController");
6 q- g6 ^9 z/ ~/ x ! _! R' @/ C9 t- L: n& `
if (simple.IsSimulationRunning())
; q" v/ F0 ]$ U9 r' U WScript.Echo("Simulation is running!");
9 {9 O$ I! t8 r | * i# g4 ?) `+ N& W" j0 f& g. A
// Wait until simulation is finished
9 g. q6 U; a( Xwhile (!Finished) WScript.Sleep(2000);
4 ~; O5 M5 t* w
7 u! h5 c6 H4 p, ?7 bsimple.CloseModel();
1 D# ^) w A) h; Msimple.Quit(); / }( P& u. l: r5 j9 u' a
WScript.Quit();
( Y8 Z0 D: Q( r2 v$ D, J $ i0 g; m' ~& [* a4 @% C* i
+ E y9 |% Q- T+ B
function RemoteControl_SimulationFinished() $ [3 A9 D5 ?1 i a' V' P: d4 w
{
2 K3 J& |0 H2 c) t WScript.Echo("Simulation Finished!"); |