Example of a JScript
$ K. h |! d H" Q: @0 w: {0 Xvar vbOKCancel = 1;
4 Q* b6 @% P* t$ K6 p7 avar vbCancel = 2; - J- t# ~; g8 _
var vbInformation = 64; - c. g. p% L% X
var Finished=false;
1 ~5 O, a" Q# G! r1 L$ S! ~ & u5 a5 ~6 j2 K% N) j% U
var WSHShell = new ActiveXObject("WScript.Shell"); 9 P4 v! s$ h; s
& P2 _# T. @4 I) r
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 p( m; H* o) H. d- p
, J& M4 M! `9 H! P7 bsimple.SetLicenseType("Runtime"); 6 k% R' R( w! W. a7 U
; i1 ?% N- `* U) e8 X2 ?try 0 C$ O& H. d* L3 f! H
{
' g5 F3 y# ?5 d% ~; r // Enter the path to a model file! . I( n4 j% R4 p t# S; p
simple.LoadModel("C:\\Models\\Test.spp"); : c# m: w" I/ a5 l$ K7 o5 X* S
} ( X# L3 s1 L4 _, R* b# I& q; u
catch (e)
/ d1 E* s3 n% g3 O9 n2 r- m{ * `# i t# E8 x; k5 q5 [
WScript.Echo("Could not load Model!"); % C( K2 K+ n+ ^
WScript.Quit(); $ @, {0 `3 ]" V( q1 s1 T
}
* g) ?1 j0 m' w5 a 6 `( u, n6 P9 ^. y+ }1 u
try $ b: E) e) c0 M% _% H
{ 3 n7 h7 }" g. F" J. X
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 M4 ? i# @5 J# ?% M* U r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
% K R2 Z& o# c7 y* u4 n if (r == vbCancel)
/ ^2 x) c0 H$ u+ D9 m( O {
9 f* q, K$ q2 Z$ B7 f simple.CloseModel(); : O- U$ n8 |/ K/ s/ I0 M" B. x
WScript.Quit();
s8 `9 ]5 F' \0 S i }
1 q/ b; \/ ~0 y& ?. [, u}
9 a2 ]0 {% m0 i; i, L
n9 P, z2 H1 d( M7 }8 m- ~1 Msimple.StartSimulation(".Models.Frame.EventController"); 3 W5 E ]9 g3 i
. z* ^! _" {4 \4 _6 _1 i
if (simple.IsSimulationRunning())
8 {, P9 |/ Q* d* [ WScript.Echo("Simulation is running!");
! R3 c; K7 f5 m6 D$ k% E
: L; G2 P. w+ \. M// Wait until simulation is finished 2 O* S7 a& l; d. ~2 D8 {# i# T
while (!Finished) WScript.Sleep(2000); ' l0 F- {! H( E
8 ^/ D4 a5 k+ {! c i/ Bsimple.CloseModel(); 8 Z% S: g, e, W* P% x# |( \! f
simple.Quit();
* W0 l# r& ^9 nWScript.Quit();
% K* Q5 H* N' M: M! P, h ( J' }" R: r1 X5 o
& K1 U T: L) w$ o, ?5 i) H& Ufunction RemoteControl_SimulationFinished() 5 H8 ^: F. T5 b% ~- U( v
{
2 }2 M& E1 W: f; s. h: ?1 [ WScript.Echo("Simulation Finished!"); |