Commit 48a0b190 authored by Gino Tosti's avatar Gino Tosti
Browse files

added

parent 80cadf11
......@@ -31,9 +31,7 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
private doubleBlobData[] blobDataSeq_m =null;
private CBdoublePOA server;
private ROdouble property_m;
......@@ -41,12 +39,7 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
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;
......@@ -84,21 +77,21 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
//blobDataSeq_m[curSeqPos_m].value = value;
//blobDataSeq_m[curSeqPos_m].time = c.timeStamp;
// Increment current position pointer
System.out.print("--->Received:"+value);
//System.out.print("--->Received:"+value);
curSeqPos_m++;
// Increment initial position pointer if buffer is full
if (bufferFull)
{
System.out.println("Data lost from buffer");
m_logger.warning("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 ))
if ( seqLen_m < (prealocSeqLen_m))
{
m_logger.info("Creating new buffer segment and adding data to it");
m_logger.fine("Creating new buffer segment and adding data to it");
// Create new segment
seqLen_m = seqLen_m + prealocSeqLen_m;
// blobDataSeq_m.length(seqLen_m);
......@@ -110,7 +103,7 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
//blobDataSeq_m[curSeqPos_m].value = value;
//blobDataSeq_m[curSeqPos_m].time = c.timeStamp;
// Increment current position pointer
m_logger.info("-->Received:"+value);
m_logger.fine("-->Received:"+value);
curSeqPos_m++;
}
else // No more segments allowed
......@@ -123,8 +116,8 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
// 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;
blobDataSeq_m[curSeqPos_m].value = value;
blobDataSeq_m[curSeqPos_m].time = c.timeStamp;
// Increment current position pointer
curSeqPos_m++;
}
......@@ -185,10 +178,9 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
}
catch(SystemException ex)
{
ex.printStackTrace();
m_logger.severe("Problems activating servant:"+ex.getMessage());
} catch (AcsJContainerServicesEx e) {
// TODO Auto-generated catch block
e.printStackTrace();
m_logger.severe("Problems with Container services:"+e.getMessage());
}
}
......@@ -202,7 +194,7 @@ public class MPdouble extends MonitorPointHelper implements CBdoubleOperations {
}
catch(SystemException | AcsJContainerServicesEx ex)
{
ex.printStackTrace();
m_logger.severe("Problems with CORBA/Container services:"+ex.getMessage());
}
}
......
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());
}
}
}
......@@ -44,6 +44,7 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
*/
private String monitorControllerInstanceName = "ARCHIVE/TMCDB/MONITOR_CONTROL";
private Controller monitorControl;
private boolean isRegistered=false;
/*
* Monitored components maps, thread safe.
......@@ -82,16 +83,18 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
monitorControl = ControllerHelper
.narrow(monitorControllerRef);
monitorControl.registerCollector(name());
if (!isRegistered)
isRegistered=true;
} catch (AcsJContainerServicesEx e) {
// TODO: is this correct?
throw new ComponentLifecycleException(e);
} catch (CollectorRegistrationFailedEx e) {
// TODO: deal with this exception, e.g. raise an alarm.
System.out.println("---> Failed registration");
m_logger.info("---> Failed registration");
}
System.out.println("---> Claudio MonitorCollector v. 0.1");
m_logger.info("---> Claudio MonitorCollector v. 0.1");
}
......@@ -105,9 +108,13 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
// For the moment ComponentImplBase.cleanUp() does nothing
super.cleanUp();
monitorControl.deregisterCollector(name());
monitorComponents.clear();
if (isRegistered) {
if (!monitorControl._non_existent())
monitorControl.deregisterCollector(name());
if (!monitorComponents.isEmpty()) {
monitorComponents.clear();
}
}
}
......@@ -123,7 +130,7 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
String serialNumber) throws RegisteringDeviceProblemEx,
DeviceAlreadyRegisteredEx {
System.out.println("---> registerMonitoredDevice");
m_logger.info("---> registerMonitoredDevice");
registerCollocatedMonitoredDevice(componentName, serialNumber);
}
......@@ -139,7 +146,7 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
String serialNumber) throws RegisteringDeviceProblemEx,
DeviceAlreadyRegisteredEx {
System.out.println("---> registerCollocatedMonitoredDevice");
m_logger.info("---> registerCollocatedMonitoredDevice");
registerMonitoredComponentWithSerial(componentName, serialNumber, true);
}
......@@ -213,11 +220,11 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
public void deregisterMonitoredDevice(String componentName)
throws DeviceNotRegisteredEx {
System.out.println("---> deregisterMonitoredDevice "+componentName);
m_logger.info("---> deregisterMonitoredDevice "+componentName);
for (String k : monitorComponents.keySet()) {
System.out.println("---> deregisterMonitoredDevice monitored component key "+k);
m_logger.info("---> deregisterMonitoredDevice monitored component key "+k);
}
System.out.flush();
//System.out.flush();
if (monitorComponents.containsKey(componentName)) {
......@@ -227,12 +234,12 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
mc.stopMonitoring();
}
System.out.println("---> deregisterMonitoredDevice - stopped monitoring "+componentName);
System.out.flush();
m_logger.info("---> deregisterMonitoredDevice - stopped monitoring "+componentName);
//System.out.flush();
for (String k : monitorComponents.keySet()) {
System.out.println("---> monitored component key "+k);
System.out.flush();
m_logger.info("---> monitored component key "+k);
//System.out.flush();
}
// remove the component from monitorComponents
......@@ -261,7 +268,7 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
String serialNumber, boolean checkCollocation)
throws DeviceAlreadyRegisteredEx, RegisteringDeviceProblemEx {
System.out.println("---> registerMonitoredComponentWithSerial");
m_logger.info("---> registerMonitoredComponentWithSerial");
try {
MonitorComponent mc = registerMonitoredComponent(componentName,
......@@ -404,9 +411,9 @@ public class MonitorCollectorImpl extends ComponentImplBase implements
public void stopMonitoring(String componentName)
throws StopMonitoringProblemEx {
System.out.println("---> stopMonitoring");
m_logger.info("---> stopMonitoring");
for (String k : monitorComponents.keySet()) {
System.out.println("---> monitored component key "+k);
m_logger.info("---> monitored component key "+k);
}
if (monitorComponents.containsKey(componentName)) {
......
......@@ -94,17 +94,22 @@ public abstract class MonitorPointHelper extends MonitorPointBase implements Ca
this.propertyName_m=propertyName;
this.archivingInterval_m=archivingInterval;
this.property_m =propertyRef;
monitorBlob_m=mb;
monitorBlob_m.archiveOnChange = false;
monitorBlob_m.propertyName = propertyName;
monitorBlob_m.blobDataSeq = ORB.init().create_any();
m_logger=log;
valueTrigger_m =0;
/*try
try
{
Any anyCharacteristic = ORB.init().create_any() ;
String strCharacteristic;
anyCharacteristic = property_m.get_characteristic_by_name("archive_suppress");
strCharacteristic = anyCharacteristic.extract_string();
if ( strCharacteristic.equals("false")) {
System.out.println("----------------->Archive Suppress:"+strCharacteristic);
if ( strCharacteristic.equals("true")) {
m_logger.info("Values from property "+ propertyName_m+" will NOT be collected because archive_suppress is set to:"+strCharacteristic);
//monitorSuppressed_m = true;
monitorSuppressed_m = true;
}
double archiveMaxInt;
Any anyCharacteristic1 = ORB.init().create_any() ;
......@@ -121,7 +126,7 @@ public abstract class MonitorPointHelper extends MonitorPointBase implements Ca
m_logger.info("CORBA problem in MonitorPoint:"+ ex.getMessage());
} catch(Exception e) {
m_logger.info("Problems in MonitorPoint:"+ e.getMessage());
}*/
}
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment