-
Notifications
You must be signed in to change notification settings - Fork 1
/
GestorEstacionBuB.cpp
201 lines (172 loc) · 4.98 KB
/
GestorEstacionBuB.cpp
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// GestorEstacionBuB.cpp: implementation of the CGestorEstacionBuB class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "tpc.h"
#include "GestorEstacionBuB.h"
#include "dbestacion.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*
CGestorEstacionBuB::CGestorEstacionBuB()
{
int AnzahlPosLage = 0; // Number of positions ?
for (int i = 1; i <= KMAX_STATIONEN; i++)
{
AnzahlPosLage += statdat[i].pos_anz_r;
AnzahlPosLage += statdat[i].pos_anz_l;
}
for (int i = 1; i <= KMAX_STATIONEN ; i++)
{
// Lefthand side
for (int pos = 0; pos < statdat [i].pos_anz_l; pos++)
{
CEstacionBuB * ptrEst = new CEstacionBuB;
m_EstacionPtrArray.Add (ptrEst);
ptrEst->Init (i, pos, 'L');
}
// right side
for (int pos = 0; pos < statdat [i].pos_anz_r; pos++)
{
CEstacionBuB * ptrEst = new CEstacionBuB;
m_EstacionPtrArray.Add (ptrEst);
ptrEst->Init (i, pos, 'R');
}
} // for
}
*/
CGestorEstacionBuB::CGestorEstacionBuB()
{
// TODO this->InitStations();
}
CGestorEstacionBuB::~CGestorEstacionBuB()
{
}
void CGestorEstacionBuB::InitStations()
{
this->m_pCourse = g_pCourseData->GetPtrCourseAGVType(1);
int nStations = this->m_pCourse->GetNumberDestinations();
int AnzahlPosLage = 0; // Number of positions ?
//for (int i = 1; i <= KMAX_STATIONEN; i++)
for (int i = 0; i < nStations; i++)
{
AnzahlPosLage += this->m_pCourse->GetPtrDestinationByIndex(i)->GetRightPositions();
//AnzahlPosLage += statdat[i].pos_anz_l;
AnzahlPosLage += this->m_pCourse->GetPtrDestinationByIndex(i)->GetLeftPositions();
}
//for (int i = 1; i <= KMAX_STATIONEN; i++)
for (int i = 0; i < nStations; i++)
{
// Lefthand side
//for (int pos = 0; pos < statdat[i].pos_anz_l; pos++)
CAGVTDestination* pDestination = this->m_pCourse->GetPtrDestinationByIndex(i);
for (int pos = 1; pos <= (int)pDestination->GetLeftPositions(); pos++)
{
if (g_pCourseData->IsAIDStation(pDestination->GetNumber(), 'L', (int)pos, (int)1))
{
CEstacionBuB * ptrEst = new CEstacionBuB;
m_EstacionPtrArray.Add(ptrEst);
ptrEst->Init(i, pos, 'L');
}
}
// right side
//for (int pos = 0; pos < statdat[i].pos_anz_r; pos++)
for (UINT pos = 1; pos <= pDestination->GetRightPositions(); pos++)
{
if (g_pCourseData->IsAIDStation(pDestination->GetNumber(), 'R', (int)pos, (int)1))
{
CEstacionBuB * ptrEst = new CEstacionBuB;
m_EstacionPtrArray.Add(ptrEst);
ptrEst->Init(i, pos, 'R');
}
}
} // for
}
void CGestorEstacionBuB::SetPtrCourse(CCourseAGVType* pCourse)
{
this->m_pCourse = pCourse;
}
CEstacionBuB * CGestorEstacionBuB::SetEstacionBuB(UINT mp, UINT pos, UCHAR lage, bool fError, bool fCargado)
{
CEstacionBuB * ptrEstBuB = NULL;
UINT numStations = m_EstacionPtrArray.GetSize ();
for (UINT i = 0; i < numStations; i++)
{
ptrEstBuB = m_EstacionPtrArray.GetAt (i);
if (ptrEstBuB->IsThis (mp, pos, lage))
{
ptrEstBuB->UpdateEstacion (fError, fCargado);
break;
}
}
return (ptrEstBuB);
}
// Actualizar datos de los descansos
void CGestorEstacionBuB::SetEstacionBuB(UINT mp, UINT pos, UCHAR lage, LPCTSTR estDes, UINT nAgvDes)
{
CEstacionBuB * ptrEstBuB = NULL;
UINT numStations = m_EstacionPtrArray.GetSize ();
for (UINT i = 0; i < numStations; i++)
{
ptrEstBuB = m_EstacionPtrArray.GetAt (i);
if (ptrEstBuB->IsThis (mp, pos, lage))
{
ptrEstBuB->UpdateEstacion (estDes, nAgvDes);
break;
}
}
}
//Actualitza el BuB en cas de simulació
void CGestorEstacionBuB::UpdateEstacion()
{
CEstacionBuB * ptrEstBuB = NULL;
UINT numStations = m_EstacionPtrArray.GetSize ();
for (UINT i = 0; i < numStations; i++)
{
ptrEstBuB = m_EstacionPtrArray.GetAt (i);
// Solo interesan estaciones de carga/descarga
if (ptrEstBuB->IsCargaDescarga())
{
CDBEstacion dbEstacion;
if (dbEstacion.GetEstAgv(ptrEstBuB->m_mp, ptrEstBuB->m_pos, ptrEstBuB->m_lage))
{
if (dbEstacion.GetNumeroMesas() > 0)
{
ptrEstBuB->UpdateEstacion(
dbEstacion.m_OcuPulmon,
dbEstacion.m_CapPulmon,
dbEstacion.GetCodEstPul(), // Michael 12.12.2004 Esto no es el pulmón de vacio asociado
dbEstacion.m_pEstAgv1->errmesa != 0,
dbEstacion.m_pEstAgv1->prepal[0] == 'S');
if (dbEstacion.GetNumeroMesas() > 1)
ptrEstBuB->UpdateEstacion(
dbEstacion.m_OcuPulmon,
dbEstacion.m_CapPulmon,
dbEstacion.GetCodEstPul(),
dbEstacion.m_pEstAgv2->errmesa != 0,
dbEstacion.m_pEstAgv2->prepal[0] == 'S');
}
}
}
}
}
CEstacionBuB * CGestorEstacionBuB::FindEstacionBuB(LPCTSTR psClientName)
{
CEstacionBuB * ptrEstBuB = NULL;
UINT numStations = m_EstacionPtrArray.GetSize ();
for (UINT i = 0; i < numStations; i++)
{
ptrEstBuB = m_EstacionPtrArray.GetAt (i);
if (ptrEstBuB->IsThis(psClientName))
{
return ptrEstBuB;
}
}
return NULL;
}