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
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.typeOfValue = alma.TMCDB.doubleValueType.value;
//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
curSeqPos_m++;
// Increment initial position pointer if buffer is full
if (bufferFull)
{
curSeqInit_m++;
}
}
else // Current available buffer segments are full
{
// Another segment can be created
// 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
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 = c.timeStamp;
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
// 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)
{
} catch (AcsJContainerServicesEx e) {
}
}
@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)
{
m_logger.severe("Problems with CORBA/Container services:"+ex.getMessage());
}
}
}