-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhangar.cpp
More file actions
87 lines (67 loc) · 2.44 KB
/
hangar.cpp
File metadata and controls
87 lines (67 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
/** include files **/
#include <string>
/** my include files **/
#include "modulo.h" // class modulo
#include "message.h" // class ExternalMessage, InternalMessage
#include "parsimu.h" // ParallelMainSimulator::Instance().getParameter( ... )
using namespace std;
/** public functions **/
/*******************************************************************
* Function Name: modulo
* Description:
********************************************************************/
modulo::modulo( const string &name )
: Atomic( name )
, recibe_avion( this->addInputPort( "recibe_avion" ) )
, emergencia( this->addOutputPort( "emergencia" ) )
, sigue_avion( this->addOutputPort( "sigue_avion" ) )
, salida_hangar( this->addOutputPort( "salida_hangar" ) )
, en_uso( this->addOutputPort( "en_uso" ) )
{
string time( ParallelMainSimulator::Instance().getParameter( this->description(), "preparation" ) ) ;
if( time != "" )
preparationTime = time ;
}
/*******************************************************************
* Function Name: initFunction
* Precondition: El tiempo del proximo evento interno es ...
********************************************************************/
Model &modulo::initFunction()
{
avion_numero=0 ;
velocidad=0
return *this ;
}
/*******************************************************************
* Function Name: externalFunction
* Description:
********************************************************************/
Model &modulo::externalFunction( const ExternalMessage &msg )
{
if( msg.port() == recibe_avion )
{
avion_numero = msg.value() ;
velocidad = floor(msg.value()) ;//Toma su parte entera
avion_numero = avion_numero - velocidad ; //El Id del vuelo queda en avion_numero
this->holdIn( active, preparationTime );
}
return *this;
}
/*******************************************************************
* Function Name: internalFunction
* Description:
********************************************************************/
Model &modulo::internalFunction( const InternalMessage & )
{
this->passivate();
return *this ;
}
/*******************************************************************
* Function Name: outputFunction
* Description:
********************************************************************/
Model &modulo::outputFunction( const InternalMessage &msg )
{
this->sendOutput( msg.time(), sigue_avion , (velocidad + avion_numero)) ;
return *this ;
}