-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduction.cpp
More file actions
87 lines (74 loc) · 2.44 KB
/
production.cpp
File metadata and controls
87 lines (74 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*******************************************************************
*
* DESCRIPTION: Atomic Model Production
*
* AUTHOR: Abdullah Alfaify
*
* EMAIL: mailto://aalfa064@uottawa.ca
*
* DATE: 14/12/2011
*
*******************************************************************/
/** include files **/
#include "production.h" // class Production
#include "message.h" // class ExternalMessage, InternalMessage
#include "mainsimu.h" // MainSimulator::Instance().getParameter( ... )
/** public functions **/
/*******************************************************************
* Function Name: Production
* Description:
********************************************************************/
Production::Production( const string &name )
: Atomic( name )
, in( addInputPort( "in" ) )
, out( addOutputPort( "out" ) )
, fpCount( addOutputPort( "fpCount" ) )
, done( addOutputPort( "done" ) )
, preparationTime( 0, 0, 8, 0 )
{ string time( MainSimulator::Instance().getParameter( description(), "preparation" ) ) ;
if( time != "" )
preparationTime = time ;
}
/*******************************************************************
* Function Name: initFunction
* Description:
********************************************************************/
Model &Production::initFunction()
{
counter = 0;
this-> passivate();
return *this ;
}
/*******************************************************************
* Function Name: externalFunction
* Description:
********************************************************************/
Model &Production::externalFunction( const ExternalMessage &msg )
{
if( msg.port() == in )
{
holdIn(active, preparationTime ); // call output function
}
return *this;
}
/*******************************************************************
* Function Name: internalFunction
* Description:
********************************************************************/
Model &Production::internalFunction( const InternalMessage & )
{
passivate();
return *this ;
}
/*******************************************************************
* Function Name: outputFunction
* Description:
********************************************************************/
Model &Production::outputFunction( const InternalMessage &msg )
{
sendOutput( msg.time(), out, 1 ) ;
counter++;
sendOutput( msg.time(), fpCount, counter ) ; // send counter
sendOutput ( msg.time(), done, 1 );
return *this ;
}