Example of a JScript + m% [+ C. i" i. G) V7 t9 r
var vbOKCancel = 1;
( p2 W4 v* g+ b3 ?% @var vbCancel = 2;
. x) Q# I& R1 u0 X' Y bvar vbInformation = 64; $ l+ G9 t" d# I- @0 J5 [' s
var Finished=false; / g% O! a/ c9 T( ]2 p" J1 Q/ a; O4 k
/ U$ |, t2 h2 \. {, n1 x
var WSHShell = new ActiveXObject("WScript.Shell");
4 M2 ^( e" | d% ?' |3 F ; A! ]9 ^ d7 s9 k( Y
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); - J6 v, n0 H0 D7 P; R
P' J/ W1 x- `; f3 b& I- ^simple.SetLicenseType("Runtime");
. m6 {9 e% O$ }+ I* `6 G : |/ y8 v7 d$ X% W+ ?$ s
try
! L( W E* g) [. H* @% D2 d{ 1 @/ K9 O) `% g# i/ F g* ?
// Enter the path to a model file! 6 @8 _# c% }5 f
simple.LoadModel("C:\\Models\\Test.spp"); # O2 ]) t/ x4 w5 I5 K% X7 w% g
} 5 b4 K# ~- A5 m9 W6 F
catch (e) & \% e( J+ E, i: m! O: q3 U
{ " }0 K! p0 P, R3 y
WScript.Echo("Could not load Model!");
- P4 ?% u& C. e s3 ]1 a WScript.Quit();
4 B# x# S% W* r8 Q; P- Q} $ G. a2 j# @7 r; E- q3 v
% W/ ^0 w G' L- d5 etry 3 j4 F0 U# Q7 O
{ 1 J; Y/ E7 t ^) }5 x _
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
' `7 n' ~8 m4 D r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 7 k! O4 }0 v8 |% _! s
if (r == vbCancel) $ F2 j, V |7 T
{
4 _6 L d" p R% o3 R$ ~ simple.CloseModel();
0 l0 T- v: j) n+ X2 G WScript.Quit(); 4 ^0 V- G" ? @" y: |/ y* i, z1 f
}
/ f4 `, s R+ p}
! S+ e$ V- V. F4 P7 i# y- H ; K7 `) y- | d# [! l* E! U6 Q
simple.StartSimulation(".Models.Frame.EventController"); 2 v, G d1 B6 _8 w' l* ^
. T* f( }6 h% Z( xif (simple.IsSimulationRunning())
5 r7 x) w0 B }- x WScript.Echo("Simulation is running!"); " r, M* V1 b7 {+ O
$ v- F) X6 r0 [$ W K% Z
// Wait until simulation is finished 4 i9 t) q: O( L2 \8 g1 W# N
while (!Finished) WScript.Sleep(2000); K) y5 [" g+ |0 `2 ~; {6 b6 p# v* F
1 O" Z" t; b6 F6 Q5 S. n: l3 ksimple.CloseModel(); $ r3 }7 K/ U# \9 Z4 i
simple.Quit();
/ l" ~# X) M5 \- a) U% @WScript.Quit(); 4 w) b( h3 i* V
4 `- a' p% _& z- n) a( a/ o 9 M$ X }& z( o& o. T& F& W" Y
function RemoteControl_SimulationFinished()
4 ~3 t3 {0 J$ L. O" F' f{ ( U5 ]1 Y7 m4 L0 O* v7 y' v" `
WScript.Echo("Simulation Finished!"); |