home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Homebrewer's Handbook
/
vr.iso
/
vroom
/
soakpit.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-03-19
|
34KB
|
994 lines
program soakpit;
uses swoop, swoop_discrete, vroom, graph, swoop_vr, clock1, fix_math, bar3d, cyberman;
const batch_size=9;
type terminal_pos=object
x,y,z : real;
free : boolean;
thisentity : entityptr;
destination : integer;
nextprocess : process;
permission : resource;
constructor Init(xpos, ypos, zpos : real; next_process : process);
end;
ingot_slot_type=record
thisentity : entityptr;
dx, dy : real;
end;
entity_attptr=^entity_att;
entity_att=record
crane, pit : integer;
last : boolean;
end;
pit_ob=object
pit_therm : z_level_bar2d;
pit_pic, lid_pic : file_object3d;
furnace_temp, ingot_temp : statevar;
furnace_const, ingot_const, fuel : real;
free, turned, heating, lid_opening : boolean;
pit_no, next_slot : integer;
ingot_slot : array[1..batch_size] of ingot_slot_type;
arrive_in_pit, let_crane_go, heat_up, call_crane, store_crane_info, seize_mill_separately, seize_terminal, wait
: process;
constructor Init(number : integer; x,y : real; turn : boolean);
procedure Open_Lid(start, open_time : real);
procedure Close_Lid(start, close_time : real);
procedure Calculate;
procedure Ingot_Colour;
end;
crane_obptr=^crane_ob;
crane_ob=object(processob)
picture, top_cable, bot_cable : file_object3d;
crane_entity, carried_entity : entityptr;
present_terminal, route_pos, next_stop : integer;
ready_to_travel, moving, free, lowering : boolean;
unit_time, lowering_time : real;
this_route : array[1..13] of integer;
procedure Request(destination : integer);
procedure Reset_Position;
procedure Execute(thisentity : entityptr); virtual;
constructor Init(initial_terminal : integer; init_unit_time : real);
procedure Monitor; virtual;
function Check : boolean; virtual;
end;
seize_pitobptr=^seize_pitob;
seize_pitob=object(seize_topob)
this_terminal : integer;
constructor Init(terminal_no, init_priority : integer; max_queue_length : real; x1, y1, z1, x2, y2, z2 : real);
procedure Monitor; virtual;
function Check : boolean; virtual;
end;
seize_craneobptr=^seize_craneob;
seize_craneob=object(seize_topob)
this_terminal : integer;
constructor Init(terminal_no, init_priority : integer; max_queue_length : real);
procedure Monitor; virtual;
function Check : boolean; virtual;
end;
var temp_ingot, temp_panzer, temp_flattop, temp_lid, temp_crane, temp_cable, temp_rolled, roller_picture : file_object3d;
crane : array [1..2] of crane_ob;
pit : array [1..17] of pit_ob;
routing : array[1..21,1..21,1..13] of integer;
terminals : array[1..32] of terminal_pos;
panzer_create, flattop_create, panzer_picture, flattop_picture, set_att, seize_track, delay_track, release_track,
send_to_pits, call_crane, timing_start, timing_proc, timing_delay, first_flattop, first_panzer,
put_on_loading_bay, let_crane_go, ingot_to_roller, dump_ingot_picture, strip_picture, to_end1,
load_ingot_waiting, ingot_on_loading_bay, replicator, wait_until_unloaded, release_terminals, release_loading_bay,
dump_waggon, lose_waggon_picture, get_next_ingot : process;
back_to_roller1, flatter1, back_to_start, back_to_roller2, flatter2, to_end2, dump_last_picture, release_roller : process;
rolling_mill, loading_bay, track : resource;
my_clock : clock_3d;
mouse, cyber, clock_selected : boolean;
pit_data : array[1..17] of boolean;
{$F+}
procedure Arrive_in_pit_proc;
var this_att : entity_attptr;
temppic : copy_object3d_ptr;
i : integer;
begin
this_att:=simulation.thisentity^.attributes;
temppic:=simulation.thisentity^.picture;
i:=pit[this_att^.pit].next_slot;
with pit[this_att^.pit].ingot_slot[i] do
begin
thisentity:=simulation.thisentity;
temppic^.MoveTo(dx,dy,0);
end;
pit[this_att^.pit].Close_Lid(now+10,20);
simulation.thisentity^.ChangeTime(simulation.time+crane[this_att^.crane].lowering_time);
end;
procedure Let_crane_go_proc;
var this_att : entity_attptr;
i : integer;
begin;
this_att:=simulation.thisentity^.attributes;
i:=pit[this_att^.pit].next_slot;
if i<>batch_size then
begin
crane[this_att^.crane].Request(18);
simulation.thisentity^.ChangeTime(infinity);
pit[this_att^.pit].ingot_temp.state:=1100;
pit[this_att^.pit].furnace_temp.state:=1100;
end
else
begin
crane[this_att^.crane].free:=true;
pit[this_att^.pit].heating:=true;
end;
inc(pit[this_att^.pit].next_slot);
end;
procedure crane_info_proc;
var i, crane_no, pit_no : integer;
this_att : entity_attptr;
begin
this_att:=simulation.thisentity^.attributes;
crane_no:=this_att^.crane;
pit_no:=this_att^.pit;
for i:=1 to batch_size do
begin
this_att:=pit[pit_no].ingot_slot[i].thisentity^.attributes;
this_att^.crane:=crane_no;
end;
end;
procedure pit_unload_proc;
var this_att : entity_attptr;
temppic : copy_object3d_ptr;
begin
this_att:=simulation.thisentity^.attributes;
temppic:=simulation.thisentity^.picture;
terminals[this_att^.pit].thisentity:=simulation.thisentity;
terminals[this_att^.pit].destination:=21;
temppic^.MoveTo(terminals[this_att^.pit].x,terminals[this_att^.pit].y,2.5);
with pit[this_att^.pit] do
begin
heating:=false;
dec(next_slot);
ingot_slot[next_slot].thisentity:=nil;
simulation.thisentity^.ChangeTime(infinity);
if (next_slot)>1 then
begin
ingot_slot[next_slot-1].thisentity^.ChangeTime(simulation.time);
ingot_slot[next_slot-1].thisentity^.ChangeProc(pit[this_att^.pit].seize_mill_separately);
this_att^.last:=false;
end
else
this_att^.last:=true;
end;
end;
procedure lid_proc(this_obj : object3d_ptr);
var i : integer;
begin
for i:=1 to 17 do if (@pit[i].lid_pic=this_obj) then
begin
if pit[i].lid_opening then pit[i].close_lid(now,30)
else pit[i].open_lid(now,30);
end;
end;
procedure pit_proc(this_obj : object3d_ptr);
var i : integer;
begin
for i:=1 to 17 do if (@pit[i].pit_pic=this_obj) then pit_data[i]:=not(pit_data[i]);
end;
procedure clock_proc(this_obj : object3d_ptr);
begin
clock_selected:=not(clock_selected);
end;
{$F-}
{------------------------------------------------}
{ Terminal pos method implementations }
{------------------------------------------------}
constructor Terminal_pos.Init(xpos, ypos, zpos : real; next_process : process);
begin
x:=xpos; y:=ypos; z:=zpos;
nextprocess:=next_process;
thisentity:=nil;
destination:=0;
free:=true;
permission.Set_Capacity(1);
end;
{------------------------------------------------}
{ Pit_ob method implementations }
{------------------------------------------------}
constructor Pit_ob.Init(number: integer; x,y : real; turn : boolean);
var i : integer;
begin
turned:=turn;
pit_no:=number;
furnace_const:=0.0005;
ingot_const:=0.00018;
fuel:=0;
furnace_temp.Initial_Value(1100);
ingot_temp.Initial_Value(1100);
heating:=false;
lid_opening:=false;
pit_pic.Init('Pit.3d');
pit_pic.Set_Reference_Point(5,5,0);
pit_pic.Select_procedure:=pit_proc;
lid_pic.Init('PitLid.3d');
lid_pic.Select_procedure:=lid_proc;
if not(turned) then lid_pic.Set_Reference_Point(5,0,10)
else lid_pic.Set_Reference_Point(5,10,10);
pit_pic.AddChild(@lid_pic);
pit_pic.MoveTo(x,y,0);
pit_therm.Init(@furnace_temp.state,1000,2200,x,y-7,0,2,10,3,1,6,1);
{ if turn then pit_therm.Init(@furnace_temp.state,1000,2500,x,y-6,0,2,10,3,6)
else
begin
pit_therm.Init(@furnace_temp.state,1000,2200,x,y+6,0,2,10,3,6);
pit_therm.RotateZ(180);
end; }
free:=true;
arrive_in_pit:=userproc(arrive_in_pit_proc);
let_crane_go:=userproc(let_crane_go_proc);
heat_up:=delay_until(@ingot_temp.state,GT,2000,0.1,infinity);
call_crane:=new(seize_craneobptr,Init(pit_no,2,100));
store_crane_info:=userproc(crane_info_proc);
seize_mill_separately:=seize(@rolling_mill,5,1);
seize_terminal:=seize(@terminals[pit_no].permission,5,1);
wait:=userproc(pit_unload_proc);
arrive_in_pit^.Link(let_crane_go);
let_crane_go^.Link(heat_up);
heat_up^.Link(call_crane);
call_crane^.Link(store_crane_info);
store_crane_info^.Link(seize_terminal);
seize_mill_separately^.Link(seize_terminal);
seize_terminal^.Link(wait);
ingot_slot[1].dx:=-2.5; ingot_slot[1].dy:=2.5;
ingot_slot[2].dx:=0; ingot_slot[2].dy:=2.5;
ingot_slot[3].dx:=2.5; ingot_slot[3].dy:=2.5;
ingot_slot[4].dx:=-2.5; ingot_slot[4].dy:=0;
ingot_slot[5].dx:=2.5; ingot_slot[5].dy:=0;
ingot_slot[6].dx:=-2.5; ingot_slot[6].dy:=-2.5;
ingot_slot[7].dx:=0; ingot_slot[7].dy:=-2.5;
ingot_slot[8].dx:=2.5; ingot_slot[8].dy:=-2.5;
ingot_slot[9].dx:=0; ingot_slot[9].dy:=0;
for i:=1 to batch_size do
begin
ingot_slot[i].thisentity:=nil;
ingot_slot[i].dx:=ingot_slot[i].dx+x;
ingot_slot[i].dy:=ingot_slot[i].dy+y;
end;
next_slot:=1;
end;
procedure Pit_ob.Open_Lid(start, open_time : real);
var i : integer;
temppic : copy_object3d_ptr;
begin
if lid_opening then exit;
lid_opening:=true;
if turned=false then lid_pic.timed_rotateX(90,start,open_time)
else lid_pic.timed_rotateX(-90,start,open_time);
for i:=1 to batch_size do
if ingot_slot[i].thisentity<>nil then
begin
temppic:=ingot_slot[i].thisentity^.picture;
temppic^.Show;
end;
end;
procedure Pit_ob.Close_Lid(start, close_time : real);
var i : integer;
temppic : copy_object3d_ptr;
begin
if not lid_opening then exit;
lid_opening:=false;
if turned=false then lid_pic.timed_rotateX(-90,start,close_time)
else lid_pic.timed_rotateX(90,start,close_time);
for i:=1 to batch_size do
if ingot_slot[i].thisentity<>nil then
begin
temppic:=ingot_slot[i].thisentity^.picture;
temppic^.Hide;
end;
end;
procedure Pit_ob.Calculate;
begin
if heating then
begin
if furnace_temp.state<2200 then fuel:=1 else fuel:=0;
furnace_temp.dot:=furnace_const*fuel*(2500-furnace_temp.state);
ingot_temp.dot:=ingot_const*(furnace_temp.state-ingot_temp.state);
end
else
begin
furnace_temp.dot:=0;
ingot_temp.dot:=0;
end;
end;
procedure Pit_ob.Ingot_Colour;
var i : integer;
temppic : copy_object3d_ptr;
shade : real;
begin
if next_slot<=batch_size then exit;
shade:=(ingot_temp.state-1100)/(2000-1100);
shade:=shade/2+0.5;
for i:=1 to batch_size do
if ingot_slot[i].thisentity<>nil then
begin
temppic:=ingot_slot[i].thisentity^.picture;
temppic^.Change_Colour(3,shade);
end;
end;
{------------------------------------------------}
{ Crane_ob method implementations }
{------------------------------------------------}
constructor crane_ob.Init(initial_terminal : integer; init_unit_time : real);
var temp : monitorptr;
begin
processob.Init;
ready_to_travel:=false;
moving:=false;
free:=true;
lowering:=false;
picture.Init('crane.3d');
picture.Set_Reference_Point(0,0,0);
picture.Scale(2,2,2);
top_cable.Init('cable.3d');
top_cable.Set_Reference_Point(0,0,0);
picture.AddChild(@top_cable);
bot_cable.Init('cable.3d');
bot_cable.Set_Reference_Point(0,0,0);
top_cable.AddChild(@bot_cable);
present_terminal:=initial_terminal;
terminals[present_terminal].free:=false;
with terminals[present_terminal] do
picture.MoveTo(x,y,z);
unit_time:=init_unit_time;
lowering_time:=20;
temp:=new(monitorptr,Init(@thisprocess,1));
crane_entity:=new(entityptr,Init(infinity,@thisprocess));
carried_entity:=nil;
end;
procedure crane_ob.Request(destination : integer);
var i : integer;
begin
for i:=1 to 13 do
this_route[i]:=routing[present_terminal,destination,i];
route_pos:=1;
ready_to_travel:=true;
if (destination>0) and (destination<18) then
begin
if destination=present_terminal then
pit[destination].open_lid(now,20)
else pit[destination].open_lid(now+30,20);
end;
end;
procedure crane_ob.Reset_Position;
var source, dest : vertex_ptr;
begin
dest:=picture.first_vertex;
source:=temp_crane.first_vertex;
while (source<>nil) and (dest<>nil) do
begin
with terminals[present_terminal] do
begin
dest^.world.x:=source^.world.x+Real_to_fixed(x);
dest^.world.y:=source^.world.y+Real_to_fixed(y);
dest^.world.z:=source^.world.z+Real_to_fixed(z);
end;
source:=source^.next;
dest:=dest^.next;
end;
dest:=top_cable.first_vertex;
source:=temp_cable.first_vertex;
while (source<>nil) and (dest<>nil) do
begin
with terminals[present_terminal] do
begin
dest^.world.x:=source^.world.x+Real_to_fixed(x);
dest^.world.y:=source^.world.y+Real_to_fixed(y);
dest^.world.z:=source^.world.z+Real_to_fixed(z);
end;
source:=source^.next;
dest:=dest^.next;
end;
dest:=bot_cable.first_vertex;
source:=temp_cable.first_vertex;
while (source<>nil) and (dest<>nil) do
begin
with terminals[present_terminal] do
begin
dest^.world.x:=source^.world.x+Real_to_fixed(x);
dest^.world.y:=source^.world.y+Real_to_fixed(y);
dest^.world.z:=source^.world.z+Real_to_fixed(z);
end;
source:=source^.next;
dest:=dest^.next;
end;
end;
procedure crane_ob.Execute(thisentity : entityptr);
var ent_picture : copy_object3d_ptr;
begin
if moving then
begin
if this_route[route_pos]<>0 then
begin
terminals[present_terminal].free:=true;
present_terminal:=this_route[route_pos];
inc(route_pos);
end;
if this_route[route_pos]<>0 then
begin
with terminals[this_route[route_pos]] do
picture.timed_moveto(x,y,z,now,unit_time);
crane_entity^.ChangeTime(simulation.time+unit_time);
end
else
begin
moving:=false;
Reset_Position;
lowering:=true;
crane_entity^.ChangeTime(simulation.time+lowering_time);
bot_cable.Timed_MoveTo(terminals[present_terminal].x,terminals[present_terminal].y,20,now,lowering_time);
end;
end
else
if lowering then
begin
crane_entity^.ChangeTime(infinity);
lowering:=false;
if carried_entity<>nil then
begin
carried_entity^.ChangeTime(simulation.time);
carried_entity^.ChangeProc(terminals[present_terminal].nextprocess);
ent_picture:=carried_entity^.picture;
bot_cable.RemoveChild(ent_picture);
carried_entity:=nil;
if terminals[present_terminal].nextprocess=nil then writeln('Entity gets lost at terminal ',present_terminal);
next_stop:=0;
end
else
if terminals[present_terminal].thisentity<>nil then
begin
if terminals[present_terminal].destination=present_terminal then
begin
terminals[present_terminal].thisentity^.ChangeTime(simulation.time);
terminals[present_terminal].thisentity^.ChangeProc(terminals[present_terminal].nextprocess);
next_stop:=0;
if terminals[present_terminal].permission.Release(terminals[present_terminal].thisentity)=false then
writeln('Error releasing terminal ',present_terminal);
terminals[present_terminal].thisentity:=nil;
end
else
begin
carried_entity:=terminals[present_terminal].thisentity;
ent_picture:=carried_entity^.picture;
bot_cable.AddChild(ent_picture);
if present_terminal=18 then
begin
ent_picture^.RotateY(-90);
ent_picture^.MoveTo(terminals[18].x,terminals[18].y,2.5);
end;
next_stop:=terminals[present_terminal].destination;
end;
end;
crane_entity^.ChangeTime(simulation.time+lowering_time);
bot_cable.Timed_MoveTo(terminals[present_terminal].x,terminals[present_terminal].y,30,now,lowering_time);
end
else
begin
crane_entity^.ChangeTime(infinity);
if next_stop<>0 then
begin
Request(next_stop);
if terminals[present_terminal].permission.Release(terminals[present_terminal].thisentity)=false then
writeln('Error releasing terminal ',present_terminal);
terminals[present_terminal].thisentity:=nil;
if (present_terminal<18) then
begin
pit[present_terminal].close_lid(now+30,20);
if pit[present_terminal].next_slot=1 then pit[present_terminal].free:=true;
end;
end;
end;
end;
function crane_ob.Check : boolean;
var res : boolean;
i : integer;
begin
res:=true;
if ready_to_travel then
begin
for i:=1 to 13 do if this_route[i]<>0 then res:=res and terminals[this_route[i]].free;
end
else res:=false;
Check:=res;
end;
procedure crane_ob.Monitor;
var i : integer;
begin
ready_to_travel:=false;
for i:=1 to 13 do
if this_route[i]<>0 then terminals[this_route[i]].free:=false;
moving:=true;
if this_route[1]<>0 then
begin
with terminals[this_route[route_pos]] do
picture.timed_moveto(x,y,z,now,unit_time);
crane_entity^.ChangeTime(simulation.time+unit_time);
end
else
crane_entity^.ChangeTime(simulation.time+20);
end;
{------------------------------------------------}
{ Seize pit method implementations }
{------------------------------------------------}
constructor seize_pitob.Init(terminal_no, init_priority : integer; max_queue_length : real; x1, y1, z1, x2, y2, z2 : real);
begin
thisqueue:=new(anim_queue_3dptr,Init(x1, y1, z1, x2, y2, z2));
seize_topob.Init(@loading_bay, max_queue_length, init_priority);
this_terminal:=terminal_no;
end;
procedure seize_pitob.Monitor;
var thisentity : entityptr;
this_att : entity_attptr;
i : integer;
result : boolean;
begin
thisentity:=thisqueue^.Remove;
if thisentity<>nil then
begin
result:=thisresource^.Seize(thisentity);
thisentity^.ChangeTime(simulation.time);
thisentity^.ChangeProc(nextprocess);
this_att:=thisentity^.attributes;
i:=1;
while not(pit[i].free) do inc(i);
this_att^.pit:=i;
pit[i].free:=false;
if crane[1].free then this_att^.crane:=1 else this_att^.crane:=2;
crane[this_att^.crane].Request(this_terminal);
crane[this_att^.crane].free:=false;
end;
end;
function seize_pitob.Check;
var test : boolean;
i : integer;
begin
test:=false;
if thisqueue^.length>0 then
begin
for i:=1 to 17 do test:=test or pit[i].free;
test:=test and ((crane[1].free or crane[2].free) and seize_topob.Check)
end;
Check:=test;
end;
{------------------------------------------------}
{ Seize crane method implementations }
{------------------------------------------------}
constructor seize_craneob.Init(terminal_no, init_priority : integer; max_queue_length : real);
begin
thisqueue:=new(queueptr,Init);
seize_topob.Init(@rolling_mill, max_queue_length, init_priority);
this_terminal:=terminal_no;
end;
procedure seize_craneob.Monitor;
var thisentity : entityptr;
this_att : entity_attptr;
i : integer;
result : boolean;
begin
thisentity:=thisqueue^.Remove;
if thisentity<>nil then
begin
result:=thisresource^.Seize(thisentity);
thisentity^.ChangeTime(simulation.time);
thisentity^.ChangeProc(nextprocess);
this_att:=thisentity^.attributes;
if crane[1].free and (crane[1].present_terminal=this_terminal) then this_att^.crane:=1
else if crane[2].free and (crane[2].present_terminal=this_terminal) then this_att^.crane:=2
else if crane[1].free then this_att^.crane:=1
else this_att^.crane:=2;
crane[this_att^.crane].Request(this_terminal);
crane[this_att^.crane].free:=false;
end;
end;
function seize_craneob.Check;
var test : boolean;
i : integer;
begin
if thisqueue^.length>0 then
Check:=((crane[1].free or crane[2].free) and seize_topob.Check)
else
Check:=false;
end;
{------------------------------------------------}
{$F+}
procedure Calculate;
var i : integer;
begin
for i:=1 to 17 do pit[i].Calculate;
end;
procedure text_display;
var temp_str1, temp_str2, temp_str3 : string;
xpos, ypos, zpos, zpos2, last_z, i, i2 : integer;
begin
if clock_selected then
begin
Str(round(simulation.time) mod 60 : 2,temp_str1);
Str((round(simulation.time) mod 3600) div 60 : 2,temp_str2);
Str(trunc(simulation.time / 3600):0,temp_str3);
my_clock.face.Screen_Position(xpos,ypos,zpos);
write_text_at(round((xpos-4)/8)-3,round((ypos-4)/8),temp_str3+':'+temp_str2+':'+temp_str1,3,1.0,2,1.0);
end;
last_z:=$7FFF;
repeat
i2:=0;
zpos2:=integer($8000);
for i:=1 to 17 do if pit_data[i] then
begin
pit[i].pit_pic.Screen_Position(xpos,ypos,zpos);
if (zpos>zpos2) and (zpos<last_z) then
begin
i2:=i; zpos2:=zpos;
end;
end;
if i2<>0 then
begin
pit[i2].pit_pic.Screen_Position(xpos,ypos,zpos);
xpos:=round((xpos-4)/8);
ypos:=round((ypos-4)/8);
Str(pit[i2].furnace_temp.state : 5 : 0,temp_str1);
Str(pit[i2].ingot_temp.state : 5 : 0,temp_str2);
Str(i2 : 5,temp_str3);
write_text_at(xpos,ypos, '╔═══════════════════╗',2,0,6,0.8);
write_text_at(xpos,ypos+1,'║Pit number :'+temp_str3+'║',2,0,6,0.8);
write_text_at(xpos,ypos+2,'║Furnace temp.:'+temp_str1+'║',2,0,6,0.8);
write_text_at(xpos,ypos+3,'║Ingot temp. :'+temp_str2+'║',2,0,6,0.8);
write_text_at(xpos,ypos+4,'╚═══════════════════╝',2,0,6,0.8);
end;
last_z:=zpos2;
until i2=0;
end;
procedure Update_Screen;
var junk1 : boolean;
i : integer;
begin
if cyber then junk1:=Cyberman_Check;
if mouse then junk1:=Mouse_Check;
junk1:=KeyBoard_Check;
for i:=1 to 17 do
begin
pit[i].pit_therm.Update;
pit[i].Ingot_Colour;
end;
redraw_scene;
end;
function My_KeyCheck(key : char) : boolean;
var f : text;
test : boolean;
temp1 : pointer;
temp2 : delayptr;
pit_no : integer;
begin
test:=true;
if key='>' then
begin
temp1:=timing_delay;
temp2:=temp1;
temp2^.first:=temp2^.first*2;
end
else
if key='<' then
begin
temp1:=timing_delay;
temp2:=temp1;
temp2^.first:=temp2^.first/2;
end
else
if key='o' then
begin
write_text_at(5,15,'Open Pit: Enter number :- ',5,1.0,0,1.0);
readln(pit_no);
if (pit_no>0) and (pit_no<18) then pit[pit_no].open_lid(now,30);
end
else
if key='c' then
begin
write_text_at(5,15,'Close Pit: Enter number :- ',5,1.0,0,1.0);
readln(pit_no);
if (pit_no>0) and (pit_no<18) then pit[pit_no].close_lid(now,30);
end
else
test:=false;
My_KeyCheck:=test;
end;
procedure loading_bay_proc;
var i : integer;
temp : process;
temppic : copy_object3d_ptr;
begin
temppic:=simulation.thisentity^.picture;
temppic^.MoveTo(240,55,0);
temp:=simulation.thisentity^.nextprocess;
for i:=1 to batch_size do replicator^.Execute(simulation.thisentity);
{simulation.thisentity^.ChangeProc(temp);
simulation.thisentity^.ChangeTime(infinity);}
end;
procedure ingot_loading_bay_proc;
var this_att : entity_attptr;
temppic : copy_object3d_ptr;
begin
temppic:=new(copy_object3d_ptr,Init(@temp_ingot));
temppic^.redraw:=true;
simulation.thisentity^.picture:=temppic;
terminals[18].thisentity:=simulation.thisentity;
this_att:=simulation.thisentity^.attributes;
terminals[18].destination:=this_att^.pit;
simulation.thisentity^.ChangeTime(infinity);
end;
procedure Let_crane_go_proc2;
var this_att : entity_attptr;
temppic : copy_object3d_ptr;
begin
this_att:=simulation.thisentity^.attributes;
temppic:=simulation.thisentity^.picture;
temppic^.RotateX(90);
if this_att^.last then crane[this_att^.crane].free:=true;
end;
procedure Next_ingot_proc;
var this_att : entity_attptr;
begin
this_att:=simulation.thisentity^.attributes;
if not(this_att^.last) then crane[this_att^.crane].Request(this_att^.pit);
end;
{$F-}
procedure Initialise_Routings;
var s,f,i : integer;
rf : text;
begin
assign(rf,'routing.dat');
reset(rf);
for s:=1 to 21 do
for f:=1 to 21 do
begin
for i:=1 to 13 do read(rf,routing[s,f,i]);
readln(rf);
end;
close(rf);
for i:= 21 to 32 do with terminals[i] do
begin
Init((i-21)*20,55,30,nil);
end;
with terminals[18] do
begin
Init(240,55,30,nil);
end;
for i:= 1 to 7 do with terminals[i] do
begin
pit[i].Init(i,i*20,35,false);
Init(i*20,35,30,pit[i].arrive_in_pit);
end;
with terminals[19] do
begin
Init(220,35,30,nil);
end;
with terminals[20] do
begin
Init(180,35,30,nil);
end;
for i:= 8 to 17 do with terminals[i] do
begin
pit[i].Init(i,(i-7)*20+20,75,true);
Init((i-7)*20+20,75,30,pit[i].arrive_in_pit);
end;
for i:=1 to 17 do pit_data[i]:=false;
end;
begin
mouse:=false; cyber:=false;
if cyberman_available then cyber:=true
else if mouse_available then mouse:=true;
simulation.Init;
init_system;
set_for_swoop;
graphics_time:=@simulation.time;
clock_selected:=false;
Set_Ambient_Intensity(1);
{ Set_Light(0.75,0,-1,-0.75);
Set_View(200,0,0,0,0,0); }
Set_View(72236320/65536,-17222016/65536,5440032/65536,-18,-4.7,0);
Store_Settings;
User_KeyCheck_Proc(My_KeyCheck);
set_text_proc(text_display);
simulation.Continuous(1,1,0,Calculate);
simulation.Integrate_Method(Euler);
{ simulation.Run_Time(Update_Screen); }
loading_bay.Set_Capacity(1);
track.Set_Capacity(1);
rolling_mill.Set_Capacity(1);
roller_picture.Init('Mill.3d');
roller_picture.Set_Reference_Point(5,5,0);
roller_picture.MoveTo(0,105,0);
roller_picture.Scale(1.4,4,1);
Initialise_Routings;
crane[1].Init(1,30);
crane[2].Init(8,30);
temp_crane.Init('crane.3d');
temp_crane.Set_Reference_Point(0,0,0);
temp_crane.Scale(2,2,2);
temp_crane.Hide;
temp_cable.Init('cable.3d');
temp_cable.Set_Reference_Point(0,0,0);
temp_cable.Hide;
temp_panzer.Init('panzer.3d');
temp_panzer.Set_Reference_Point(0,0,0);
temp_panzer.Hide;
temp_flattop.Init('flattop.3d');
temp_flattop.Set_Reference_Point(0,0,0);
temp_flattop.Hide;
temp_rolled.Init('rolled.3d');
temp_rolled.Set_Reference_Point(5,8.5,0);
temp_rolled.Hide;
temp_ingot.Init('box.3d');
temp_ingot.Set_Reference_Point(0,5,5);
temp_ingot.Scale(0.7,0.1,0.1);
temp_ingot.Change_Colour(3,0.5);
temp_ingot.MoveTo(236,55,2.5);
temp_ingot.Hide;
my_clock.Init(-40,55,30,60*60,3600*12);
my_clock.Hand1.Change_Colour(7,0.7);
my_clock.Hand2.Change_Colour(7,0.7);
my_clock.Face.Select_Procedure:=clock_proc;
{sort_by_furthest_point;}
timing_start:=create(constant,1,0,0,1);
timing_proc:=userproc(update_screen);
timing_delay:=delay(constant,1,0,0);
timing_start^.Link(timing_proc);
timing_proc^.Link(timing_delay);
timing_delay^.Link(timing_proc);
first_panzer:=create(constant,400,0,0,1);
panzer_create:=create(uniform,11000,15000,0,infinity);
panzer_picture:=copy_picture3d(@temp_panzer);
first_flattop:=create(constant,1,0,0,1);
flattop_create:=create(uniform,8000,10000,0,infinity);
flattop_picture:=copy_picture3d(@temp_flattop);
set_att:=Set_Attributes(SizeOf(entity_att));
seize_track:=seize(@track,infinity,1);
delay_track:=delay(constant,5,0,0);
release_track:=release(@track);
send_to_pits:=route3d(constant,60,0,0,250,-100,0,250,35,0);
call_crane:=new(seize_pitobptr,Init(18,1,100,250,55,0,250,-450,0));
put_on_loading_bay:=userproc(loading_bay_proc);
wait_until_unloaded:=seize(@terminals[18].permission,1,1);
release_terminals:=release(@terminals[18].permission);
release_loading_bay:=release(@loading_bay);
dump_waggon:=route3d(constant,60,0,0,240,45,0,240,-100,0);
lose_waggon_picture:=destroy_picture3d;
replicator:=replicate;
load_ingot_waiting:=seize(@terminals[18].permission,10,2);
ingot_on_loading_bay:=userproc(ingot_loading_bay_proc);
first_panzer^.Link(panzer_picture);
panzer_create^.Link(panzer_picture);
panzer_picture^.Link(set_att);
first_flattop^.Link(flattop_picture);
flattop_create^.Link(flattop_picture);
flattop_picture^.Link(set_att);
set_att^.Link(seize_track);
seize_track^.Link(delay_track);
delay_track^.Link(release_track);
release_track^.Link(send_to_pits);
send_to_pits^.Link(call_crane);
call_crane^.Link(put_on_loading_bay);
replicator^.Link(wait_until_unloaded);
wait_until_unloaded^.Link(release_terminals);
release_terminals^.Link(release_loading_bay);
release_loading_bay^.Link(dump_waggon);
dump_waggon^.Link(lose_waggon_picture);
replicator^.Link2(load_ingot_waiting);
load_ingot_waiting^.Link(ingot_on_loading_bay);
let_crane_go:=userproc(let_crane_go_proc2);
terminals[21].nextprocess:=let_crane_go;
ingot_to_roller:=route3d(constant,100,0,0,0,55,0,0,105,0);
dump_ingot_picture:=destroy_picture3d;
strip_picture:=copy_picture3d(@temp_rolled);
to_end1:=route3d(constant,100,0,0,0,105,0,0,155,0);
back_to_roller1:=route3d(constant,100,0,0,0,155,0,0,105,0);
flatter1:=scale_picture3d(1,1.5,1);
back_to_start:=route3d(constant,100,0,0,0,105,0,0,55,0);
back_to_roller2:=route3d(constant,100,0,0,0,55,0,0,105,0);
flatter2:=scale_picture3d(1,1.5,1);
to_end2:=route3d(constant,100,0,0,0,105,0,0,155,0);
dump_last_picture:=destroy_picture3d;
release_roller:=release(@rolling_mill);
get_next_ingot:=userproc(next_ingot_proc);
let_crane_go^.Link(ingot_to_roller);
ingot_to_roller^.Link(dump_ingot_picture);
dump_ingot_picture^.Link(strip_picture);
strip_picture^.Link(to_end1);
to_end1^.Link(back_to_roller1);
back_to_roller1^.Link(flatter1);
flatter1^.Link(back_to_start);
back_to_start^.Link(back_to_roller2);
back_to_roller2^.Link(flatter2);
flatter2^.Link(to_end2);
to_end2^.Link(dump_last_picture);
dump_last_picture^.Link(release_roller);
release_roller^.Link(get_next_ingot);
redraw_scene;
simulation.Execute(infinity);
stop_graphics;
writeln('Out of time');
end.