-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
209 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* This file is part of PTN Engine | ||
* | ||
* Copyright (c) 2017 Eduardo Valgôde | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "Mocks/InhibitedPetriNet.h" | ||
#include "PTN_Engine/Place.h" | ||
|
||
|
||
using namespace ptne; | ||
using namespace std; | ||
|
||
Dispatcher::InhibitedPetriNet::InhibitedPetriNet(shared_ptr<Dispatcher> ptrDispatcher): | ||
PTN_Engine{} | ||
{ | ||
|
||
//Places | ||
addPlace("InputWaitPackage", 0, nullptr, nullptr, true); | ||
|
||
addPlace("P1",1, nullptr, nullptr); | ||
addPlace("P2",1, nullptr, nullptr); | ||
addPlace("P3",1, nullptr, nullptr); | ||
addPlace("P4",0, nullptr, nullptr); | ||
addPlace("P5",0, nullptr, nullptr); | ||
|
||
//Transitions | ||
|
||
|
||
createTransition( | ||
{"InputWaitPackage", "P1", "P3"}, //activation | ||
{"P4"}, //destination | ||
{} //additional conditions | ||
); | ||
|
||
|
||
createTransition( | ||
{"P2"}, //activation | ||
{"P5"}, //destination | ||
{}, //additional conditions | ||
{"P3"} //inhibitor arc | ||
); | ||
|
||
|
||
createTransition( | ||
{"InputWaitPackage", "P4"}, //activation | ||
{"P1", "P3"}, //destination | ||
{} //additional conditions | ||
); | ||
|
||
|
||
createTransition( | ||
{"P5"}, //activation | ||
{"P2"}, //destination | ||
{}, //additional conditions | ||
{"P4"} //inhibitor arc | ||
); | ||
|
||
} | ||
|
||
void Dispatcher::InhibitedPetriNet::dispatch() | ||
{ | ||
incrementInputPlace("InputWaitPackage"); | ||
execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file is part of PTN Engine | ||
* | ||
* Copyright (c) 2017 Eduardo Valgôde | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Mocks/Dispatcher.h" | ||
#include "Mocks/IDispatcherPetriNet.h" | ||
#include "PTN_Engine/PTN_Engine.h" | ||
|
||
//! Implements PTN Engine net with a Petri net that uses the inhibitor arc. | ||
/*! | ||
* The behaviour is defined in the constructor. | ||
*/ | ||
class Dispatcher::InhibitedPetriNet: | ||
public IDispatcherPetriNet, | ||
private ptne::PTN_Engine | ||
{ | ||
//For testing purposes. | ||
friend class FixturePetriNet; | ||
|
||
public: | ||
|
||
/*! | ||
* Constructor. | ||
* \param ptrDispatcher Shared pointer to the dispatcher. | ||
*/ | ||
InhibitedPetriNet(std::shared_ptr<Dispatcher> ptrDispatcher); | ||
|
||
//! Trigger the dispatch process. | ||
void dispatch() override; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters