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
package alma.TMCDB.MonitorCollectorImpl;
import java.util.logging.Logger;
import org.omg.CORBA.SystemException;
import alma.ACS.CBDescOut;
import alma.ACS.CBlongOperations;
import alma.ACS.CBlongPOA;
import alma.ACS.CBlongPOATie;
import alma.ACS.Property;
import alma.ACS.ROlong;
import alma.ACS.ROlongHelper;
import alma.ACSErr.Completion;
import alma.JavaContainerError.wrappers.AcsJContainerServicesEx;
import alma.TMCDB.MonitorBlob;
import alma.TMCDB.longBlobData;
import alma.TMCDB.longBlobDataSeqHelper;
import alma.acs.container.ContainerServices;
public class MPlong extends MonitorPointHelper implements CBlongOperations {
private longBlobData[] blobDataSeq_m =null;
private CBlongPOA server;
private ROlong property_m;
public MPlong(Logger log, String propertyName, long archivingInterval, Property propertyRef, MonitorBlob mb) {
super(log, propertyName, archivingInterval, propertyRef, mb);
server =new CBlongPOATie(this);
monitorBlob_m.typeOfValue = alma.TMCDB.longValueType.value;
//setMonitorServant(server);
this.blobDataSeq_m =new longBlobData[prealocSeqLen_m];
seqLen_m = prealocSeqLen_m;
try
{
property_m=ROlongHelper.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(int 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
// longBlobData a = new longBlobData();
// 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
{
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;
// 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];
longBlobData[] tmpBlobDataSeq = new longBlobData[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];
}
longBlobDataSeqHelper.insert(monitorBlob_m.blobDataSeq, tmpBlobDataSeq);
//blobDataSeq_m = new doubleBlobData[seqLen_m];
}else {
longBlobData[] tmpBlobDataSeq = new longBlobData[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];
}
longBlobDataSeqHelper.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(int 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)
{
m_logger.severe("Problems activating servant:"+ex.getMessage());
} catch (AcsJContainerServicesEx e) {
m_logger.severe("Problems with Container services:"+e.getMessage());
}
}
@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());
}
}
}