SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
src
output2.cc
Go to the documentation of this file.
1
/////////////////////////////////////////////////////////////////////////////
2
//! \file output2.cc Output subsystem implementation
3
//
4
// Copyright (c) 1991-2004 Petr Peringer
5
//
6
// This library is licensed under GNU Library GPL. See the file COPYING.
7
//
8
9
//
10
// Output methods for all discrete classes
11
//#error Split into parts!!!!
12
//
13
14
////////////////////////////////////////////////////////////////////////////
15
// interface
16
//
17
18
#include "
simlib.h
"
19
#include "
internal.h
"
20
21
#include <cstdio>
// sprintf()
22
23
24
////////////////////////////////////////////////////////////////////////////
25
// implementation
26
//
27
28
namespace
simlib3
{
29
30
SIMLIB_IMPLEMENTATION
;
31
32
////////////////////////////////////////////////////////////////////////////
33
// Facility::Output
34
//
35
void
Facility::Output
()
const
36
{
37
char
s[100];
38
Print
(
"+----------------------------------------------------------+\n"
);
39
Print
(
"| FACILITY %-47s |\n"
,
Name
().c_str());
40
Print
(
"+----------------------------------------------------------+\n"
);
41
sprintf(s,
" Status = %s "
, (
Busy
()) ?
"BUSY"
:
"not BUSY"
);
42
Print
(
"| %-56s |\n"
,s);
43
if
(
tstat
.
Number
()>0)
44
{
45
sprintf(s,
" Time interval = %g - %g "
,
tstat
.
StartTime
(), (
double
)
Time
);
46
Print
(
"| %-56s |\n"
, s);
47
Print
(
"| Number of requests = %-28ld |\n"
,
tstat
.
Number
());
48
if
(
Time
>
tstat
.
StartTime
())
49
Print
(
"| Average utilization = %-27g |\n"
,
tstat
.
MeanValue
());
50
}
51
Print
(
"+----------------------------------------------------------+\n"
);
52
53
if
(
OwnQueue
())
54
{
55
if
(
Q1
->
StatN
.
Number
()>0)
// used
56
{
57
Print
(
" Input queue '%s.Q1'\n"
,
Name
().c_str());
58
Q1
->
Output
();
59
}
60
}
61
else
62
Print
(
" External input queue '%s'\n"
,
Q1
->
Name
().c_str());
63
64
if
(
Q2
->
StatN
.
Number
()>0)
// used
65
{
66
Print
(
" Interrupted services queue '%s.Q2'\n"
,
Name
().c_str());
67
Q2
->
Output
();
68
}
69
70
Print
(
"\n"
);
71
}
72
73
////////////////////////////////////////////////////////////////////////////
74
// Histogram::Output
75
//
76
void
Histogram::Output
()
const
77
{
78
Print
(
"+----------------------------------------------------------+\n"
);
79
Print
(
"| HISTOGRAM %-46s |\n"
,
Name
().c_str());
80
//Print("+----------------------------------------------------------+\n");
81
stat
.
Output
();
82
long
sum = 0;
83
unsigned
i;
84
for
(i=0; i<=
count
+1; i++)
85
sum +=
dptr
[i];
86
if
(sum==0)
return
;
87
//Print("+------------+------------+----------+----------+----------+\n");
88
Print
(
"| from | to | n | rel | sum |\n"
);
89
Print
(
"+------------+------------+----------+----------+----------+\n"
);
90
double
from =
low
;
91
long
s =
dptr
[0];
92
for
(i=1; i<=
count
; i++)
93
{
94
unsigned
x =
dptr
[i];
95
s += x;
96
double
to = from+
step
;
97
Print
(
"| %10.3f | %10.3f | %8u | %8.6f | %8.6f |\n"
,
98
from, to, x, (
double
)x/sum, (
double
)s/sum);
99
from = to;
100
}
101
Print
(
"+------------+------------+----------+----------+----------+\n"
);
102
Print
(
"\n"
);
103
}
104
105
////////////////////////////////////////////////////////////////////////////
106
// Process::Output
107
//
108
void
Process::Output
()
const
109
{
110
Print
(
" PROCESS %-38s %10s \n"
,
Name
().c_str(),
isCurrent
()?
"Current"
:
" "
);
111
}
112
113
////////////////////////////////////////////////////////////////////////////
114
// Queue::Output
115
//
116
void
Queue::Output
()
const
117
{
118
Print
(
"+----------------------------------------------------------+\n"
);
119
Print
(
"| QUEUE %-39s %10s |\n"
,
Name
().c_str(),
StatN
.
Number
()?
""
:
"not used"
);
120
if
(
StatN
.
Number
() > 0)
121
{
122
Print
(
"+----------------------------------------------------------+\n"
);
123
char
s[100];
// FIXME: "100 bytes should be enough"
124
sprintf(s,
" Time interval = %g - %g "
,
StatN
.
StartTime
(), (
double
)
Time
);
125
Print
(
"| %-56s |\n"
, s);
126
Print
(
"| Incoming %-26ld |\n"
,
StatN
.
Number
());
127
Print
(
"| Outcoming %-26ld |\n"
,
StatDT
.
Number
());
128
Print
(
"| Current length = %-26lu |\n"
,
size
());
129
Print
(
"| Maximal length = %-25g |\n"
,
StatN
.
Max
());
130
double
dt = double(
Time
) -
StatN
.
StartTime
();
131
if
(dt>0)
132
{
133
double
mv =
StatN
.
MeanValue
();
134
Print
(
"| Average length = %-25g |\n"
,mv);
135
}
136
if
(
StatDT
.
Number
()>0)
137
{
138
Print
(
"| Minimal time = %-25g |\n"
,
StatDT
.
Min
());
139
Print
(
"| Maximal time = %-25g |\n"
,
StatDT
.
Max
());
140
double
mv =
StatDT
.
MeanValue
();
141
Print
(
"| Average time = %-25g |\n"
, mv);
142
if
(
StatDT
.
Number
()>99)
143
Print
(
"| Standard deviation = %-25g |\n"
,
144
StatDT
.
StdDev
());
145
}
146
}
147
Print
(
"+----------------------------------------------------------+\n"
);
148
#ifdef XXX_PRINT_QUEUE_
149
// only for debug
150
{
151
Print
(
"Queue contents:\n"
);
152
unsigned
u;
153
iterator
p;
154
for
(p=
begin
(), u=1; p!=
end
(); ++p, u++) {
155
Print
(
" [%u]:\t"
,u);
156
(*p)->Output();
157
}
158
Print
(
"End of queue.\n"
);
159
}
160
#endif
161
}
162
163
////////////////////////////////////////////////////////////////////////////
164
// Stat::Output
165
//
166
void
Stat::Output
()
const
167
{
168
Print
(
"+----------------------------------------------------------+\n"
);
169
Print
(
"| STATISTIC %-46s |\n"
,
Name
().c_str());
170
Print
(
"+----------------------------------------------------------+\n"
);
171
if
(
n
==0)
172
Print
(
"| no record |\n"
);
173
else
174
{
175
Print
(
"| Min = %-15g Max = %-15g |\n"
,
min
,
max
);
176
Print
(
"| Number of records = %-26ld |\n"
,
n
);
177
Print
(
"| Average value = %-25g |\n"
,
MeanValue
());
178
if
(
n
>99)
179
Print
(
"| Standard deviation = %-25g |\n"
,
StdDev
());
180
}
181
Print
(
"+----------------------------------------------------------+\n"
);
182
}
183
184
////////////////////////////////////////////////////////////////////////////
185
// Store::Output
186
//
187
void
Store::Output
()
const
188
{
189
char
s[100];
190
Print
(
"+----------------------------------------------------------+\n"
);
191
Print
(
"| STORE %-50s |\n"
,
Name
().c_str());
192
Print
(
"+----------------------------------------------------------+\n"
);
193
sprintf(s,
" Capacity = %lu (%lu used, %lu free) "
,
194
Capacity
(),
used
,
Free
());
195
Print
(
"| %-56s |\n"
,s);
196
if
(
tstat
.
n
>0)
197
{
198
sprintf(s,
" Time interval = %g - %g "
,
tstat
.
StartTime
(), (
double
)
Time
);
199
Print
(
"| %-56s |\n"
, s);
200
Print
(
"| Number of Enter operations = %-24ld |\n"
,
tstat
.
Number
());
201
Print
(
"| Minimal used capacity = %-30g |\n"
,
tstat
.
Min
());
202
Print
(
"| Maximal used capacity = %-30g |\n"
,
tstat
.
Max
());
203
if
(
Time
>
tstat
.
StartTime
())
204
Print
(
"| Average used capacity = %-30g |\n"
,
tstat
.
MeanValue
());
205
}
206
Print
(
"+----------------------------------------------------------+\n"
);
207
if
(
OwnQueue
())
208
{
209
if
(
Q
->
StatN
.
Number
()>0)
// byla pouzita
210
{
211
Print
(
" Input queue '%s.Q'\n"
,
Name
().c_str());
212
Q
->
Output
();
213
}
214
}
215
else
216
Print
(
" External input queue '%s'\n"
,
Q
->
Name
().c_str());
217
Print
(
"\n"
);
218
}
219
220
////////////////////////////////////////////////////////////////////////////
221
// TStat::Output
222
//
223
void
TStat::Output
()
const
224
{
225
Print
(
"+----------------------------------------------------------+\n"
);
226
Print
(
"| STATISTIC %-46s |\n"
,
Name
().c_str());
227
Print
(
"+----------------------------------------------------------+\n"
);
228
if
(
n
==0)
229
Print
(
"| no record |\n"
);
230
else
231
{
232
char
s[100];
233
Print
(
"| Min = %-15g Max = %-15g |\n"
,
min
,
max
);
234
sprintf(s,
" Time = %g - %g "
,
t0
, (
double
)
Time
);
235
Print
(
"| %-56s |\n"
, s);
236
Print
(
"| Number of records = %-26ld |\n"
,
n
);
237
if
(
Time
>
t0
)
238
Print
(
"| Average value = %-25g |\n"
,
MeanValue
());
239
}
240
Print
(
"+----------------------------------------------------------+\n"
);
241
}
242
243
}
244
// end of output2.cc
245
simlib3::Facility::Busy
bool Busy() const
in service
Definition
simlib.h:775
simlib3::Facility::tstat
TStat tstat
usage statistics
Definition
simlib.h:764
simlib3::Facility::Output
virtual void Output() const override
print statistics
Definition
output2.cc:35
simlib3::Facility::Q1
Queue * Q1
Input queue.
Definition
simlib.h:762
simlib3::Facility::Q2
Queue * Q2
Interrupted requests queue.
Definition
simlib.h:763
simlib3::Facility::OwnQueue
bool OwnQueue() const
test for default queue
Definition
facility.cc:282
simlib3::Histogram::step
double step
Definition
simlib.h:733
simlib3::Histogram::dptr
unsigned * dptr
Definition
simlib.h:731
simlib3::Histogram::stat
Stat stat
Definition
simlib.h:736
simlib3::Histogram::Output
virtual void Output() const override
print to default output
Definition
output2.cc:76
simlib3::Histogram::low
double low
Definition
simlib.h:732
simlib3::Histogram::count
unsigned count
Definition
simlib.h:734
simlib3::List::size
unsigned size() const
Definition
simlib.h:676
simlib3::Process::isCurrent
bool isCurrent() const
Definition
simlib.h:454
simlib3::Process::Output
virtual void Output() const override
print object to default output
Definition
output2.cc:108
simlib3::Process::Name
virtual std::string Name() const override
name of object
Definition
process.cc:214
simlib3::Queue::StatDT
Stat StatDT
Definition
simlib.h:697
simlib3::Queue::Output
virtual void Output() const override
print statistics
Definition
output2.cc:116
simlib3::Queue::end
iterator end()
Definition
simlib.h:705
simlib3::Queue::begin
iterator begin()
Definition
simlib.h:704
simlib3::Queue::iterator
List::iterator iterator
Definition
simlib.h:695
simlib3::Queue::StatN
TStat StatN
Definition
simlib.h:696
simlib3::SimObject::Name
virtual std::string Name() const
get object name
Definition
object.cc:134
simlib3::Stat::Number
unsigned long Number() const
Definition
simlib.h:584
simlib3::Stat::StdDev
double StdDev() const
Definition
stat.cc:97
simlib3::Stat::min
double min
Definition
simlib.h:572
simlib3::Stat::Max
double Max() const
Definition
simlib.h:586
simlib3::Stat::max
double max
Definition
simlib.h:573
simlib3::Stat::Min
double Min() const
Definition
simlib.h:585
simlib3::Stat::MeanValue
double MeanValue() const
Definition
stat.cc:88
simlib3::Stat::n
unsigned long n
Definition
simlib.h:574
simlib3::Stat::Output
virtual void Output() const override
print statistics
Definition
output2.cc:166
simlib3::Store::Capacity
unsigned long Capacity() const
max capacity
Definition
simlib.h:810
simlib3::Store::Output
virtual void Output() const override
print statistics
Definition
output2.cc:187
simlib3::Store::OwnQueue
bool OwnQueue() const
OwnQueue.
Definition
store.cc:203
simlib3::Store::Free
unsigned long Free() const
free capacity
Definition
simlib.h:808
simlib3::Store::tstat
TStat tstat
usage statistics
Definition
simlib.h:796
simlib3::Store::Q
Queue * Q
input queue
Definition
simlib.h:795
simlib3::Store::used
unsigned long used
Currently used capacity.
Definition
simlib.h:794
simlib3::TStat::MeanValue
double MeanValue() const
Definition
tstat.cc:96
simlib3::TStat::min
double min
Definition
simlib.h:601
simlib3::TStat::Max
double Max() const
Definition
simlib.h:619
simlib3::TStat::n
unsigned long n
Definition
simlib.h:606
simlib3::TStat::StartTime
double StartTime() const
Definition
simlib.h:622
simlib3::TStat::t0
double t0
Definition
simlib.h:603
simlib3::TStat::Output
virtual void Output() const override
print object to default output
Definition
output2.cc:223
simlib3::TStat::Number
unsigned long Number() const
Definition
simlib.h:617
simlib3::TStat::max
double max
Definition
simlib.h:602
simlib3::TStat::Min
double Min() const
Definition
simlib.h:618
internal.h
Internal header file for SIMLIB/C++.
simlib3
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
Definition
algloop.cc:32
simlib3::Time
const double & Time
model time (is NOT the block)
Definition
run.cc:48
simlib3::SIMLIB_IMPLEMENTATION
SIMLIB_IMPLEMENTATION
Definition
algloop.cc:34
simlib3::Print
int Print(const char *fmt,...)
for Output methods, can be redirected
Definition
print.cc:92
simlib.h
Main SIMLIB/C++ interface.
Generated on
for SIMLIB/C++ by
1.18.0