Hello
Hello,
I'm using Sir Rufo's TStateless framework https://github.com/SirRufo/stateless
I want to adapt my flow (see picture) like this :
Implementation
type
TWarehouseCheckInState = (New, OrderChecked, ProductChecked, CartonAdded,
Validated, Canceled);
TWarehouseCheckInTrigger = (SetOrder, SetProduct, AddCarton, Validate, Cancel);
TWarehouseCheckInStateMachine = TStateMachine
FState.Configure(TWarehouseCheckInState.New).OnEntry(
procedure
begin
FOrder := '';
FProduct := '';
FScannedBarCode := '';
end
) .Permitif(TWarehouseCheckInTrigger.SetOrder,
TWarehouseCheckInState.OrderChecked,IsOrderValid);
FState.Configure(TWarehouseCheckInState.OrderChecked).OnExit(
procedure
begin
GetCommandeFournisseur;
end).Permitif(TWarehouseCheckInTrigger.SetProduct,
TWarehouseCheckInState.ProductChecked,IsProductValid );
FState.Configure(TWarehouseCheckInState.ProductChecked)
.PermitReentryif( TWarehouseCheckInTrigger.AddCarton,IsNeverAdded );
FState.Configure(TWarehouseCheckInState.CartonAdded).OnEntry(
procedure
begin
if ProductNotAdded(FScannedBarCode ) then
AddProduct(TProduct.Create(FScannedBarCode ));
end) ;
Test code
WarehouseCheckIn := TWarehouseCheckIn.Create;
WarehouseCheckIn.State.OnTransitioned(WarehouseCheckInTransitioned);
WarehouseCheckIn.Order := '49469';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.SetOrder);
WarehouseCheckIn.Product := 'F0055';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.SetProduct);
if (WarehouseCheckIn.State.State = TWarehouseCheckInState.ProductChecked) then
begin
WarehouseCheckIn.ScanedBarCode := '1';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.AddCarton);
WarehouseCheckIn.Scan := '2';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.AddCarton);
WarehouseCheckIn.Scan := '3';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.AddCarton);
WarehouseCheckIn.Scan := '1';
WarehouseCheckIn.State.Fire(TWarehouseCheckInTrigger.AddCarton);
end;
issues i'm getting
I don't know why but onEntry event is never fired on my different states.
How should I configure my State so that I cannot add already added carton nor add cartons when there is no needs to add cartons (all products have been added) ?
Thank you
We're currently working on similar problems, and we had a quick look at SirRufo/TStateless and decided to "reinvent the wheel" instead of rolling with TStateless.
ReplyDeleteWe need more complex junctions with multiple entry paths and multiple exit paths, where orders can broken into multiple deliveries, scans could be manual or robot driven, what if there was nothing found to be delivered, or existed but was not accessible, etc.
It is difficult to answer your question to why an event doesn't happen, without knowing TStateless intimately, and have access to actual code.
Thank you Lars Fosdal. I will try to contact Sir Rufo via github as I haven't his profile on G+
ReplyDeleteI will try to step into the code but I'm really short on time.I'll maybe do it the old way (if and case statements)
Ping Oliver Münzberg
ReplyDeleteI'm sorry to say that, but you must be quite lucky to get a response from Oliver these days. He has been literally offline from one day to the other for a couple of months now. I don't know the reason. Perhaps Frank Lauter can comment on this as a close friend.
ReplyDeleteLast seen on Stack Overflow 2 hours ago...
ReplyDeleteDalija Prasnikar I'll be flamed if I post such question on S.O.
ReplyDeleteStéphane Wierzbicki I meant more like he hasn't completely disappeared rather than you should post on SO.
ReplyDeleteAnd while I haven't looked at your question close enough, it does not seem bad at first glance :)
Dalija Prasnikar His last action on SO was on November 13th. That is at least much better than I suspected. His last activity in our German forum Delphi-PRAXIS has been in August.
ReplyDeleteFWIW here is my SO question : stackoverflow.com - TStateMachine.TStateConfiguration.OnEntry is never fired
ReplyDelete