Newer
Older
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
202
203
204
205
206
207
208
209
210
package alma.TMCDB.MonitorCollectorImpl;
import java.util.logging.Logger;
import org.jacorb.orb.ORB;
import org.jacorb.poa.POA;
import org.omg.CORBA.InterfaceDef;
import org.omg.CORBA.InterfaceDefHelper;
import org.omg.CORBA.Object;
import org.omg.CORBA.SystemException;
import org.omg.PortableServer.Servant;
import alma.ACS.CBDescOut;
import alma.ACS.CBdoubleHelper;
import alma.ACS.CBdoubleOperations;
import alma.ACS.CBdoublePOA;
import alma.ACS.CBdoublePOATie;
import alma.ACS.OffShoot;
import alma.ACS.Property;
import alma.ACS.ROdouble;
import alma.ACS.ROdoubleHelper;
import alma.ACSErr.Completion;
import alma.JavaContainerError.wrappers.AcsJContainerServicesEx;
import alma.TMCDB.MonitorBlob;
import alma.TMCDB.doubleBlobData;
import alma.TMCDB.doubleBlobDataHelper;
import alma.TMCDB.doubleBlobDataSeqHelper;
import alma.acs.container.ContainerServices;
public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
private doubleBlobData[] blobDataSeq_m =null;
private CBdoublePOA server;
private ROdouble property_m;
public MPdouble(Logger log, String propertyName, long archivingInterval, Property propertyRef, MonitorBlob mb) {
super(log, propertyName, archivingInterval, propertyRef, mb);
server =new CBdoublePOATie(this);
monitorBlob_m=mb;
monitorBlob_m.archiveOnChange = false;
monitorBlob_m.typeOfValue = alma.TMCDB.doubleValueType.value;
monitorBlob_m.propertyName = propertyName;
monitorBlob_m.blobDataSeq = ORB.init().create_any();
//setMonitorServant(server);
this.blobDataSeq_m =new doubleBlobData[prealocSeqLen_m];
seqLen_m = prealocSeqLen_m;
try
{
property_m=ROdoubleHelper.narrow(propertyRef);
//m_logger.info("no such Characteristic for"+propertyName);
if(property_m.default_timer_trigger()==0){
m_logger.info("Default_timer_trigger=0 in Property:"+propertyName);
}
}
catch(Exception ex)
{
m_logger.info("no such Characteristic for"+ex.getMessage());
}
m_logger.info("INIZIALIZZATA COMPONENTE "+propertyName);
}
@Override
public void working(double value, Completion c, CBDescOut desc) {
m_logger.info("---->Working on:"+propertyName_m);
// Still place in current available buffer segments
m_logger.info("--->Received:"+value);
if ( curSeqPos_m < seqLen_m )
{
// This log is commented because of operational constraints that are currently using 'debug' as operation log setting
//ACS_SHORT_LOG((LM_DEBUG, "Adding data to buffer"));
// Add data to current position
doubleBlobData a = new doubleBlobData();
a.value = value;
a.time = c.timeStamp;
blobDataSeq_m[curSeqPos_m] = a;
//blobDataSeq_m[curSeqPos_m].value = value;
//blobDataSeq_m[curSeqPos_m].time = c.timeStamp;
// Increment current position pointer
System.out.print("--->Received:"+value);
curSeqPos_m++;
// Increment initial position pointer if buffer is full
if (bufferFull)
{
System.out.println("Data lost from buffer");
curSeqInit_m++;
}
}
else // Current available buffer segments are full
{
// Another segment can be created
if ( seqLen_m < (prealocSeqLen_m * maxSeqSegments_m ))
{
m_logger.info("Creating new buffer segment and adding data to it");
// Create new segment
seqLen_m = seqLen_m + prealocSeqLen_m;
// blobDataSeq_m.length(seqLen_m);
// Add data to current position
doubleBlobData a = new doubleBlobData();
a.value = value;
a.time = c.timeStamp;
blobDataSeq_m[curSeqPos_m] = a;
//blobDataSeq_m[curSeqPos_m].value = value;
//blobDataSeq_m[curSeqPos_m].time = c.timeStamp;
// Increment current position pointer
m_logger.info("-->Received:"+value);
curSeqPos_m++;
}
else // No more segments allowed
{
m_logger.warning("No more data segments are allowed. Buffer is full");
// Define buffer as full
bufferFull = true;
// Increment buffer initial position
curSeqInit_m++;
// Reset buffer current position
curSeqPos_m = 0;
// Add data to current position
//blobDataSeq_m[curSeqPos_m].value = value;
// blobDataSeq_m[curSeqPos_m].time = comp.timeStamp;
// Increment current position pointer
curSeqPos_m++;
}
}
}
@Override
public void fillSeq() {
//super.fillSeq();
synchronized(mutex) {
try {
if (curSeqInit_m == 0)
{
//blobDataSeq_m =new doubleBlobData[curSeqPos_m];
doubleBlobData[] tmpBlobDataSeq = new doubleBlobData[curSeqPos_m];
for (int i = 0; i < curSeqPos_m; i++) {
m_logger.info("1---> BlobDataSeq "+blobDataSeq_m[i].time+" "+blobDataSeq_m[i].value);
tmpBlobDataSeq[i] = blobDataSeq_m[i];
}
doubleBlobDataSeqHelper.insert(monitorBlob_m.blobDataSeq, tmpBlobDataSeq);
//blobDataSeq_m = new doubleBlobData[seqLen_m];
}else {
doubleBlobData[] tmpBlobDataSeq = new doubleBlobData[curSeqPos_m];
for (int i = 0; i < curSeqPos_m; i++) {
m_logger.info("2---> BlobDataSeq "+i+" "+blobDataSeq_m[i].time+" "+blobDataSeq_m[i].value);
tmpBlobDataSeq[i] = blobDataSeq_m[(i+curSeqInit_m)%seqLen_m];
}
doubleBlobDataSeqHelper.insert(monitorBlob_m.blobDataSeq, tmpBlobDataSeq);
}
}catch (Exception e) {
m_logger.severe("execption:"+e.getMessage());
}
}
curSeqPos_m = 0;
curSeqInit_m = 0;
bufferFull = false;
//System.out.println("---> fillSeq Stop, any type="+monitorBlob_m.blobDataSeq.type()+" (doubleBlobDataSeqHelper.type()=)"+doubleBlobDataSeqHelper.type());
}
@Override
public void done(double value, Completion c, CBDescOut desc) {
m_logger.info("Done!");
}
@Override
public void activate(ContainerServices containerServices_m) {
try
{
monitorServant_m = containerServices_m.activateOffShoot(server);
// At this point ref count of monitorServant_m will be 2
}
catch(SystemException ex)
{
ex.printStackTrace();
} catch (AcsJContainerServicesEx e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void deactivate(ContainerServices containerServices_m) {
try
{
containerServices_m.deactivateOffShoot(server);
// At this point ref count of monitorServant_m will be 2
}
catch(SystemException | AcsJContainerServicesEx ex)
{
ex.printStackTrace();
}
}
}