Assigned (OnDestinationValidate) then
Result: = Result and OnDestinationValidate (Destination)
end;
function TElement.GetCanTakeParcelFrom (Source : TElement): Boolean;
begin
if Assigned (OnSourceValidate) then
Result: = OnSourceValidate (Source)
else Result: = True;
end;
procedure TElement.AskForParcel;
var i: integer;
Source: TElement;
begin
for i: = 0 to SourceCount - 1 do begin
Source: = Sources [i];
if Source.CanDropParcelFor [Self] and CanTakeParcelFrom [Source] then
if CanTake then begin
Pass (i);
if Self is TShop then Exit;
end
else
if not (Source is TAccumulator) then RefuseParcel (i);
end ;//for
end;
function TElement.GetParcelPresent: Boolean;
begin
Result: = FContainer <> nil;
end;
procedure TElement.ClearContainer;
begin
DropParcel;
end;
procedure TElement.RefuseParcel (SourceIndex: integer);
begin
Sources [SourceIndex]. Container.State: = psRefused;
Sources [SourceIndex]. DropParcel;
end;
procedure TElement.DropParcel;
begin
Container: = nil;
end;
procedure TElement.DoBeforeDrop (Sender: TElement);
begin
if Assigned (FBeforeDrop) then FBeforeDrop (Sender);
end;
procedure TElement.DoAfterDrop (Sender: TElement);
begin
if Assigned (FAfterDrop) then FAfterDrop (Sender);
end;
procedure TElement.DoBeforeTake (Sender: TElement);
begin
if Assigned (FBeforeTake) then FBeforeTake (Sender);
end;
procedure TElement.DoAfterTake (Sender: TElement);
begin
if Assigned (FAfterTake) then FAfterTake (Sender);
end;
constructor TGenerator.Create;
begin
inherited;
FRandomType: = rtPlane;
end;
function TGenerator.GetRandom: TCustTime;
var R: single;
begin
case FRandomType of
rtPlane: R: = PlaneRND;
rtNormal: R: = NormRND;
rtExponent: R: = ExpRND
else
R: = Random;
end;
Result: = FMean - FDisp + Round (R * 2 * FDisp);
end;
constructor TShop.Create;
begin
inherited;
FGenerator: = TGenerator.Create;
end;
destructor TShop.Destroy;
begin
FGenerator.Free;
inherited;
end;
procedure TShop.DropParcel;
begin
inherited;
FEndWorkTime: = 0;
end;
procedure TShop.Pass (SourceIndex: integer);
begin
inherited;
Work;
end;
function TShop.G...