-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGProcessAccess.cpp
175 lines (146 loc) · 5.46 KB
/
CGProcessAccess.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
/****************************************************************************
* Modul: $RCSfile: CGProcessAccess.cpp,v $
*
* $Author: md $
* $Date: 1998/01/14 10:59:58 $
* $Revision: 1.3 $
*
* Aufgabe: Dieses Modul enthaelt Hilfsfunktionen
* Funktionen:
****************************************************************************/
#ifdef USE_PRAGMA
#pragma interface
#endif
/****************************************************************************
* Konstanten
****************************************************************************/
/****************************************************************************
* Include-Anweisungen
****************************************************************************/
#include <DS/DSProcess.h>
#include <DS/DSExpression.h>
#include <DS/DSString.h>
#include <DS/DSVariableAccess.h>
#include <DS/DSSensor.h>
#include <DS/DSBlock.h>
#include "CGFile.h"
#include "CGProcessAccess.h"
#ifdef DEBUG
#include <dmalloc.h>
#endif
/****************************************************************************
* Externe Processn
****************************************************************************/
/****************************************************************************
* Globale Processn
****************************************************************************/
/****************************************************************************
* Konstruktoren
****************************************************************************/
CGProcessAccess::CGProcessAccess(DSObject* father, // Vaterobjekt
DSProcessRef p_ref, // Referenz auf Prozess
DSExpression* p_id, // Identifizierungsnummer
DSVariableAccess* v_access): // Referenz auf Variable
DSProcessAccess(father, p_ref, p_id, v_access)
{
}
CGProcessAccess::CGProcessAccess(DSObject* father, // Vaterobjekt
DSProcessRef p_ref, // Referenz auf Prozess
DSExpression* p_id, // Identifizierungsnummer
DSSensorRef s_ref): // Referenz auf Sensor
DSProcessAccess(father, p_ref, p_id, s_ref)
{
}
/****************************************************************************
* Destruktor
****************************************************************************/
CGProcessAccess::~CGProcessAccess(void)
{
}
DSObject *CGProcessAccess::New(DSObject *father) const
{
return new CGProcessAccess(father);
}
/****************************************************************************
* Write(): schreibt den Zugriff auf eine Process
* -> writer
* -> what
* Ergebnis: DS_OK,falls Aktion erfolgreich war, sonst
* DS_ERROR
* Seiteneffekte: Zieldatei wird gefuellt
****************************************************************************/
DSResult CGProcessAccess::Write(DSWriter *writer, DSCardinal what) const
{
DSResult result;
(void)what;
result = WriteProcessAccess((CGWriter *)writer);
return result;
}
/****************************************************************************
* Write(): schreibt Zugriff auf eine Process
* -> writer
* Ergebnis: CG_OK,falls Aktion erfolgreich war, sonst
* enthaelt DSResult das Ergebnis
* Seiteneffekte: Zieldatei wird gefuellt
****************************************************************************/
DSResult CGProcessAccess::WriteProcessAccess(CGWriter *writer) const
{
DSResult result;
DSExpression * process_id;
CGFile * out;
CGPos pos;
DSProcessRef process_ref;
DSString str;
DSVariableAccess * var_access;
DSSensorRef p_sensor_ref;
DSBlockRef block_ref;
out = writer->CGGetFilePointer();
assert(out);
pos = writer->CGGetIndentPos();
process_ref = GetProcessRef();
assert(process_ref);
block_ref = process_ref->GetThisBlock();
assert(block_ref);
var_access = GetVariableAccess();
p_sensor_ref = GetSensorRef();
if (!var_access && !p_sensor_ref) // soll nur auf den Process-Typ
{ // zugegriffen werden (z.B. bei
// Sensorabfrage)
block_ref->Write(writer, CG_WRITE_IDENTIFIER);
InsertString(*out, "::", 0, CG_NO_EOL);
str.Format("%s%s",
PREFIX_PROCESS_TYPE_VARIABLE,
process_ref->GetName()->GetString());
InsertString(*out, str, 0, CG_NO_EOL);
return DS_OK;
}
InsertString(*out, "((", pos, CG_NO_EOL);
process_ref->Write(writer, CG_WRITE_IDENTIFIER);
InsertString(*out, " *)", 0, CG_NO_EOL);
process_id = GetProcessID();
if (GetProcessID())
{
InsertString(*out, "SCScheduler::GetRunnableFromID(", 0, CG_NO_EOL);
process_id->Write(writer);
InsertString(*out, ")", 0, CG_NO_EOL);
}
else
{
block_ref->Write(writer, CG_WRITE_IDENTIFIER);
InsertString(*out, "::", 0, CG_NO_EOL);
str.Format("%s%s->GetAProcess()",
PREFIX_PROCESS_TYPE_VARIABLE,
process_ref->GetName()->GetString());
InsertString(*out, str, 0, CG_NO_EOL);
}
InsertString(*out, ")->", 0, CG_NO_EOL);
if (var_access)
{
var_access->Write(writer);
}
else if (GetSensorRef())
{
p_sensor_ref->Write(writer, CG_WRITE_IDENTIFIER);
}
return result;
}