From 4ee5d983a75f1e41669d24f8b6d94fb6cb508066 Mon Sep 17 00:00:00 2001
From: Ruud Overeem <overeem@astron.nl>
Date: Tue, 10 Jun 2008 20:57:33 +0000
Subject: [PATCH] Bug 1189: Updated to the new PVSS layers. Reimplemented the
 'setDiagnoses' routine.

---
 .gitattributes                                |   1 -
 MAC/APL/PIC/MIS/configure.in                  |   4 +-
 .../PIC/MIS/src/MACInformationServer.conf.in  |   5 -
 MAC/APL/PIC/MIS/src/MISDaemon.cc              | 246 ++++++++++--------
 MAC/APL/PIC/MIS/src/MISDaemon.h               |  47 ++--
 MAC/APL/PIC/MIS/src/MISDefines.h              |  33 +--
 MAC/APL/PIC/MIS/src/MISMain.cc                |  25 +-
 MAC/APL/PIC/MIS/src/MISSession.cc             | 178 ++++---------
 MAC/APL/PIC/MIS/src/MISSession.h              |  33 +--
 MAC/APL/PIC/MIS/src/MIS_Protocol.prot         |  34 +--
 MAC/APL/PIC/MIS/src/Makefile.am               |   5 +-
 11 files changed, 260 insertions(+), 351 deletions(-)
 delete mode 100644 MAC/APL/PIC/MIS/src/MACInformationServer.conf.in

diff --git a/.gitattributes b/.gitattributes
index c560ff28343..afa5cc29507 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -351,7 +351,6 @@ MAC/APL/PAC/_VirtualTelescope/src/Makefile.am -text svneol=native#application/oc
 MAC/APL/PIC/MIS/Makefile.am -text svneol=native#application/octet-stream
 MAC/APL/PIC/MIS/bootstrap -text svneol=native#application/octet-stream
 MAC/APL/PIC/MIS/configure.in -text svneol=native#application/octet-stream
-MAC/APL/PIC/MIS/src/MACInformationServer.conf.in -text svneol=native#application/octet-stream
 MAC/APL/PIC/MIS/src/MIS_Protocol.prot -text svneol=native#application/octet-stream
 MAC/APL/PIC/MIS/src/Makefile.am -text svneol=native#application/octet-stream
 MAC/APL/PIC/MIS/test/MACall.tse.prot -text svneol=native#application/octet-stream
diff --git a/MAC/APL/PIC/MIS/configure.in b/MAC/APL/PIC/MIS/configure.in
index 52ccb14cc45..3db2f62f0ae 100644
--- a/MAC/APL/PIC/MIS/configure.in
+++ b/MAC/APL/PIC/MIS/configure.in
@@ -42,9 +42,11 @@ lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,)
 lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,)
 lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,,)
 lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Task.h,,)
+lofar_INTERNAL(MAC/GCF/PVSS, GCFPVSS, , 1, GCF/PVSS/PVSSservice.h,,)
+lofar_INTERNAL(MAC/GCF/RTDB, GCFRTDB, , 1, GCF/RTDB/RTDB_PropertySet.h,,)
 lofar_INTERNAL(MAC/APL/RTCCommon, RTCCommon, , 1, APL/RTCCommon/Timestamp.h,,)
+lofar_INTERNAL(MAC/APL/RTDBCommon, RTDBCommon, , 1, APL/RTDBCommon/RTDButilities.h,,)
 lofar_INTERNAL(MAC/APL/PIC/RSP_Protocol, RSP_Protocol, , 1, APL/RSP_Protocol/RSP_Protocol.ph,,)
-lofar_INTERNAL(MAC/APL/APLCommon, APLCommon, , 1, APL/APLCommon/APL_Defines.h,,)
 lofar_EXTERNAL(BLITZ,1,blitz/blitz.h,,,,'gnu3:-Wno-unused gnu3:-ftemplate-depth-30',,-lm)
 
 dnl
diff --git a/MAC/APL/PIC/MIS/src/MACInformationServer.conf.in b/MAC/APL/PIC/MIS/src/MACInformationServer.conf.in
deleted file mode 100644
index 678c68e9eb1..00000000000
--- a/MAC/APL/PIC/MIS/src/MACInformationServer.conf.in
+++ /dev/null
@@ -1,5 +0,0 @@
-mac.ns.APL-MISD.server.type=TCP
-mac.ns.APL-MISD.server.port=27009
-mac.top.APL-MIS.client.remoteservice=APL-MISD:server
-mac.top.APL-MISS.rspclient.remoteservice=RSPDriver:acceptor_v2
-#mac.top.APL-MISS.rspclient.remoteservice=ARATestDriver:ARAtestRSPserver
diff --git a/MAC/APL/PIC/MIS/src/MISDaemon.cc b/MAC/APL/PIC/MIS/src/MISDaemon.cc
index 638ee791b5f..feef12d416a 100644
--- a/MAC/APL/PIC/MIS/src/MISDaemon.cc
+++ b/MAC/APL/PIC/MIS/src/MISDaemon.cc
@@ -1,6 +1,6 @@
 //#  MISDaemon.cc: 
 //#
-//#  Copyright (C) 2002-2003
+//#  Copyright (C) 2002-2008
 //#  ASTRON (Netherlands Foundation for Research in Astronomy)
 //#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
 //#
@@ -25,31 +25,41 @@
 #include <Common/LofarLocators.h>
 
 #include <APS/ParameterSet.h>
-//#include <GCF/LogSys/GCF_KeyValueLogger.h>
-//#include <GCF/PAL/GCF_PVSSInfo.h>
+#include <MACIO/MACServiceInfo.h>
+#include <GCF/PVSS/GCF_PVTypes.h>
+#include <GCF/PVSS/PVSSresult.h>
+#include <GCF/RTDB/DP_Protocol.ph>
 #include <APL/RSP_Protocol/RSP_Protocol.ph>
 #include "MISSession.h"
 #include "MIS_Protocol.ph"
-#include "MISDefines.h"
+//#include "MISDefines.h"
 #include "MISDaemon.h"
 
-namespace LOFAR 
-{
-using namespace GCF::Common;
-using namespace GCF::TM;
-using namespace ACC::APS;
- namespace AMI
- {
+namespace LOFAR {
+	using namespace MACIO;
+	using namespace GCF::TM;
+	using namespace ACC::APS;
+	namespace AMI {
 
+//
+// MISDaemon()
+//
 MISDaemon::MISDaemon() :
-	GCFTask((State)&MISDaemon::initial, MISD_TASK_NAME)
+	GCFTask((State)&MISDaemon::initial, "MisDaemon")
 {
 	// register the protocol for debugging purposes
 	registerProtocol(MIS_PROTOCOL, MIS_PROTOCOL_STRINGS);
 	registerProtocol(RSP_PROTOCOL, RSP_PROTOCOL_STRINGS);
 
-	// initialize the port
-	_misdPortProvider.init(*this, MISD_PORT_NAME, GCFPortInterface::MSPP, MIS_PROTOCOL);
+	// initialize the ports
+	itsListener = new GCFTCPPort(*this, "listener", GCFPortInterface::MSPP, MIS_PROTOCOL);
+	ASSERTSTR(itsListener, "Can't allocate a listener port");
+	itsListener->setPortNumber(SHM_INFOSERVER_PORT);
+
+//	itsDPService = new DPservice(this);
+//	ASSERTSTR(itsDPservice, "Can't allocate DataPoint service");
+
+	// try to add the RemoteStation parameters to my parameterset.
 	try {
 		ConfigLocator	aCL;
 		globalParameterSet()->adoptFile(aCL.locate("RemoteStation.conf"),"");
@@ -59,109 +69,133 @@ MISDaemon::MISDaemon() :
 	}  
 }
 
+//
+// ~MISDaemon()
+//
+MISDaemon::~MISDaemon()
+{
+//	if (itsDPservice) {
+//		delete itsDPService;
+//	}
+	if (itsListener) {
+		delete itsListener;
+	}
+}
+
 
+//
+// initial(event,port)
+//
 GCFEvent::TResult MISDaemon::initial(GCFEvent& e, GCFPortInterface& p)
 {
-  GCFEvent::TResult status = GCFEvent::HANDLED;
-  switch (e.signal)
-  {
-    case F_INIT:
-      break;
-
-    case F_ENTRY:
-    case F_TIMER:
-      if (!_misdPortProvider.isConnected())
-      {
-        _misdPortProvider.open();
-      }
-      break;
-
-    case F_CONNECTED:
-      TRAN(MISDaemon::accepting);
-      break;
-
-    case F_DISCONNECTED:
-      p.setTimer(1.0); // try again after 1 second
-      break;
-
-    default:
-      status = GCFEvent::NOT_HANDLED;
-      break;
-  }
-
-  return status;
+	GCFEvent::TResult status = GCFEvent::HANDLED;
+
+	switch (e.signal) {
+	case F_INIT:
+		break;
+
+	case F_ENTRY:
+	case F_TIMER:
+		if (!itsListener->isConnected()) {
+			itsListener->open();
+		}
+	break;
+
+	case F_CONNECTED:
+		TRAN(MISDaemon::accepting);
+	break;
+
+	case F_DISCONNECTED:
+		p.setTimer(5.0); // try again after 5 second
+	break;
+
+	default:
+		status = GCFEvent::NOT_HANDLED;
+	break;
+	}
+
+	return status;
 }
 
+//
+// accepting(event.port)
+//
 GCFEvent::TResult MISDaemon::accepting(GCFEvent& e, GCFPortInterface& p)
 {
-  GCFEvent::TResult status = GCFEvent::HANDLED;
-  static unsigned long garbageTimerID = 0;
-  static unsigned long rereadPolicyTimerID = 0;
-//  static bool hasPVSS = false; 
-
-  switch (e.signal) {
-    case F_ENTRY: {
-      garbageTimerID      = _misdPortProvider.setTimer(5.0, 5.0); 
-      rereadPolicyTimerID = _misdPortProvider.setTimer(60.0, 60.0); 
-      break;
-    }
-
-    case F_DISCONNECTED:
-      DBGFAILWHEN(&_misdPortProvider == &p && "MISD port provider may not be disconnected."); 
-      break;
-      
-    case F_TIMER: {
-      GCFTimerEvent& timerEvent = static_cast<GCFTimerEvent&>(e);
-      
-      if (timerEvent.id == garbageTimerID) {
-        // cleanup the garbage of closed ports to master clients
-        MISSession* pClient;
-        for (TSessions::iterator iter = _sessionsGarbage.begin(); iter != _sessionsGarbage.end(); ++iter) {
-          pClient = *iter;
-          delete pClient;
-        }
-        _sessionsGarbage.clear();
-      }
-      else if (timerEvent.id == rereadPolicyTimerID) {
-        _policyHandler.rereadPolicyFile();
-      }      
-      break;
-    }  
-
-    case F_CLOSED:
-      DBGFAILWHEN(&_misdPortProvider == &p);
-      break;
-      
-    case F_CONNECTED:
-      DBGFAILWHEN(&_misdPortProvider == &p);
-      break;
-      
-    case F_ACCEPT_REQ: {
-      LOG_INFO("New MIS client accepted!");
-      MISSession* miss = new MISSession(*this);
-      miss->start();
-//      if (!hasPVSS) {
-        // now we have PVSS connection
-//        hasPVSS = true;        
-        // the GCFPVSSInfo::getOwnManNum() method only returns a valid
-        // man number if a PVSS connections has been established
-        // is will be automatically done by the MISSession
-//        SKIP_UPDATES_FROM(GCFPVSSInfo::getOwnManNum());
-//     }
-      break;
-    }
-    
-    default:
-      status = GCFEvent::NOT_HANDLED;
-      break;
-  }
-
-  return status;
+	GCFEvent::TResult status = GCFEvent::HANDLED;
+	static unsigned long garbageTimerID = 0;
+//	static unsigned long rereadPolicyTimerID = 0;
+//	static bool hasPVSS = false; 
+
+	switch (e.signal) {
+	case F_ENTRY: {
+		garbageTimerID      = itsListener->setTimer(5.0, 5.0); 
+//		rereadPolicyTimerID = itsListener->setTimer(60.0, 60.0); 
+		break;
+	}
+
+	case F_DISCONNECTED:
+		DBGFAILWHEN(itsListener == &p && "MISD port provider may not be disconnected."); 
+		break;
+
+	case F_TIMER: {
+		GCFTimerEvent& timerEvent = static_cast<GCFTimerEvent&>(e);
+
+		if (timerEvent.id == garbageTimerID) {
+			// cleanup the garbage of closed ports to master clients
+			MISSession* pClient;
+			for (TSessions::iterator iter = _sessionsGarbage.begin(); iter != _sessionsGarbage.end(); ++iter) {
+				pClient = *iter;
+				delete pClient;
+			}
+			_sessionsGarbage.clear();
+		}
+/*		else if (timerEvent.id == rereadPolicyTimerID) {
+			_policyHandler.rereadPolicyFile();
+		}      
+*/
+		break;
+	}  
+
+	case F_CLOSED:
+		DBGFAILWHEN(&p == itsListener);
+		break;
+
+	case F_CONNECTED:
+		DBGFAILWHEN(&p == itsListener);
+		break;
+
+	case F_ACCEPT_REQ: {
+		LOG_INFO("New MIS client accepted!");
+		MISSession* miss = new MISSession(*this);
+		miss->start();
+#if 0
+		if (!hasPVSS) {
+			// now we have PVSS connection
+			hasPVSS = true;        
+			// the GCFPVSSInfo::getOwnManNum() method only returns a valid
+			// man number if a PVSS connections has been established
+			// is will be automatically done by the MISSession
+			SKIP_UPDATES_FROM(GCFPVSSInfo::getOwnManNum());
+		}
+#endif
+		break;
+	}
+
+	default:
+		status = GCFEvent::NOT_HANDLED;
+		break;
+	}
+
+	return (status);
 }
 
+//
+// clientClosed(client)
+//
 void MISDaemon::clientClosed(MISSession& client)
 {
-  _sessionsGarbage.push_back(&client);  
+	_sessionsGarbage.push_back(&client);  
 }
 
  } // namespace AMI
diff --git a/MAC/APL/PIC/MIS/src/MISDaemon.h b/MAC/APL/PIC/MIS/src/MISDaemon.h
index 11b2f5ba9d1..af7ad7bd151 100644
--- a/MAC/APL/PIC/MIS/src/MISDaemon.h
+++ b/MAC/APL/PIC/MIS/src/MISDaemon.h
@@ -1,6 +1,6 @@
 //#  MISDaemon.h: 
 //#
-//#  Copyright (C) 2002-2003
+//#  Copyright (C) 2002-2008
 //#  ASTRON (Netherlands Foundation for Research in Astronomy)
 //#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
 //#
@@ -23,14 +23,13 @@
 #ifndef MISDAEMON_H
 #define MISDAEMON_H
 
+#include <Common/lofar_list.h>
 #include <MACIO/GCF_Event.h>
 #include <GCF/TM/GCF_Control.h>
-#include <MISPolicyHandler.h>
+//#include <MISPolicyHandler.h>
 
-namespace LOFAR 
-{
- namespace AMI 
- {  
+namespace LOFAR {
+	namespace AMI {  
 
 class MISSession;
 
@@ -39,39 +38,39 @@ class MISSession;
 
 class MISDaemon : public GCF::TM::GCFTask
 {
-  public:
+public:
     MISDaemon ();
-    virtual ~MISDaemon () {}
+    ~MISDaemon();
     
-  public: // member functions
-    GCF::TM::GCFTCPPort& getPortProvider();
-    MISPolicyHandler& getPolicyHandler();
+	// member functions
+    GCF::TM::GCFTCPPort& 	getPortProvider();
+//    MISPolicyHandler& 		getPolicyHandler();
     void clientClosed(MISSession& client);
   
-  private: // state methods
+private: 
+	// state methods
     MACIO::GCFEvent::TResult initial   (MACIO::GCFEvent& e, GCF::TM::GCFPortInterface& p);
     MACIO::GCFEvent::TResult accepting (MACIO::GCFEvent& e, GCF::TM::GCFPortInterface& p);
         
-  private: // helper methods
-    
-  private: // data members        
-    GCF::TM::GCFTCPPort  _misdPortProvider;
-    MISPolicyHandler _policyHandler;
+	// data members        
+    GCF::TM::GCFTCPPort*	itsListener;
+//	RTDB::DPservice*		itsDPservice;
+//    MISPolicyHandler		_policyHandler;
 
-  private: // admin members
+	// admin members
     typedef list<MISSession*> TSessions;
-    TSessions        _sessionsGarbage;    
+    TSessions				_sessionsGarbage;    
 };
 
 inline GCF::TM::GCFTCPPort& MISDaemon::getPortProvider()
 {
-  return _misdPortProvider;
+	return (*itsListener);
 }
 
-inline MISPolicyHandler& MISDaemon::getPolicyHandler()
-{
-  return _policyHandler;
-}
+//inline MISPolicyHandler& MISDaemon::getPolicyHandler()
+//{
+//	return (_policyHandler);
+//}
 
  } // namespace AMI
 } // namespace LOFAR
diff --git a/MAC/APL/PIC/MIS/src/MISDefines.h b/MAC/APL/PIC/MIS/src/MISDefines.h
index 266dcd59242..7bb1d163f56 100644
--- a/MAC/APL/PIC/MIS/src/MISDefines.h
+++ b/MAC/APL/PIC/MIS/src/MISDefines.h
@@ -25,41 +25,12 @@
 
 //#include <GCF/GCF_Defines.h>
 
-namespace LOFAR 
-{
- namespace AMI
- {
+namespace LOFAR {
+ namespace AMI {
 const uint8 MIS_MAJOR_VER = 1; 
 const uint8 MIS_MIDOR_VER = 1;
 const uint8 MIS_MINOR_VER = 0;
 
-const string MIS_TASK_NAME("APL-MIS");
-const string MIS_CONF("MIS.conf");
-const string MIS_PORT_NAME("client");
-
-const string MISS_TASK_NAME("APL-MISS");
-const string MISS_PORT_NAME("misd-session");
-
-const string MISD_TASK_NAME("APL-MISD");
-const string MISD_PORT_NAME("server");
-
-const string MIS_RSP_PORT_NAME("rspclient");
-
-enum {
-    RS_DEFECT = -3,
-    RS_VERIFY,
-    RS_OFFLINE,
-    RS_IDLE,
-    RS_BUSY,
-    RS_SUSPECT_IDLE = 0x40000000
-};
-
-#define IS_BUSY(s) ((s > 0) && (s != RS_SUSPECT_IDLE))
-#define IS_SUSPECT(s) (s >= RS_SUSPECT_IDLE)
-#define IS_IDLE(s) ((s == 0) || (s == RS_SUSPECT_IDLE))
-#define MAKE_SUSPECT(s) (s |= RS_SUSPECT_IDLE)
-#define MAKE_UNSUSPECT(s) (s &= ~RS_SUSPECT_IDLE)
-
  } // namespace AMI
 } // namespace LOFAR
 
diff --git a/MAC/APL/PIC/MIS/src/MISMain.cc b/MAC/APL/PIC/MIS/src/MISMain.cc
index d4396439d07..4a1a79ac20d 100644
--- a/MAC/APL/PIC/MIS/src/MISMain.cc
+++ b/MAC/APL/PIC/MIS/src/MISMain.cc
@@ -23,22 +23,21 @@
 #include <lofar_config.h>
 #include <Common/LofarLogger.h>
 
-#include <MISDaemon.h>
 #include <GCF/TM/GCF_Control.h>
+#include "MISDaemon.h"
 
-using namespace LOFAR;
+using namespace LOFAR::GCF::TM;
+using namespace LOFAR::AMI;
 
-int main(int argC, char *argV[])
+int main(int argc, char *argv[])
 {
-  GCF::TM::GCFTask::init(argC, argV);
-  
-  LOG_INFO("MACProcessScope: APL.PIC.MIS");
-  
-  AMI::MISDaemon misd; 
-  
-  misd.start(); // make initial transition
-  
-  GCF::TM::GCFTask::run();
+	GCFTask::init(argc, argv, "MACInfoServer");
+	LOG_INFO("MACProcessScope: LOFAR_PermSW_MACInfoServer");
 
-  return 0;
+	MISDaemon misd; 
+	misd.start(); // make initial transition
+
+	GCFTask::run();
+
+	return (0);
 }
diff --git a/MAC/APL/PIC/MIS/src/MISSession.cc b/MAC/APL/PIC/MIS/src/MISSession.cc
index 03e1b1e1058..df7e9e173e5 100644
--- a/MAC/APL/PIC/MIS/src/MISSession.cc
+++ b/MAC/APL/PIC/MIS/src/MISSession.cc
@@ -1,6 +1,6 @@
 //#  MISSession.cc: 
 //#
-//#  Copyright (C) 2002-2003
+//#  Copyright (C) 2002-2008
 //#  ASTRON (Netherlands Foundation for Research in Astronomy)
 //#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
 //#
@@ -21,6 +21,9 @@
 //#  $Id$
 
 #include <lofar_config.h>
+#include <Common/LofarConstants.h>
+#include <APL/RTDBCommon/RTDButilities.h>
+#include <APL/RTCCommon/PSAccess.h>
 
 #include "MISSession.h"
 #include "MISDaemon.h"
@@ -28,25 +31,16 @@
 //#include "MISSubscription.h"
 #include "XCStatistics.h"         //MAXMOD
 #include "RspStatus.h"            //MAXMOD
-//#include <GCF/PAL/GCF_PVSSInfo.h>
-//#include <GCF/PAL/GCF_Answer.h>
-//#include <APL/APLCommon/APL_Defines.h>
-//#include <GCF/GCF_PVInteger.h>
-#include <APL/RTCCommon/PSAccess.h>
-//#include <GCF/LogSys/GCF_KeyValueLogger.h>
 
 using namespace blitz;
 
 
-namespace LOFAR 
-{
-using namespace GCF::Common;
-using namespace GCF::TM;
-using namespace RTC;
-//using namespace APLCommon;
+namespace LOFAR {
+	using namespace GCF::TM;
+	using namespace RTC;
+	using namespace APL::RTDBCommon;
 
- namespace AMI
- {
+	namespace AMI {
 
 #define LOGMSGHDR(_in_)   \
     LOG_TRACE_FLOW(formatString( \
@@ -91,20 +85,25 @@ using namespace RTC;
    //MAXMOD
    unsigned int i,j;
    
+//
+// MISSession(MISDaemon)
+//
 MISSession::MISSession(MISDaemon& daemon) :
-  GCFTask((State)&MISSession::initial_state, MISS_TASK_NAME),
-  _daemon(daemon),
-//  _propertyProxy(*this),
-  _curSeqNr(1),
-  _curReplyNr(0),
-  _pRememberedEvent(0),
-  _nrOfRCUs(0)
+	GCFTask((State)&MISSession::initial_state, "MISSession"),
+	_daemon			 	 (daemon),
+	_curSeqNr			 (1),
+	_curReplyNr			 (0),
+	_pRememberedEvent	 (0),
+	_nrOfRCUs			 (0)
 {
-  _missPort.init(*this, MISS_PORT_NAME, GCFPortInterface::SPP, MIS_PROTOCOL);
-  _rspDriverPort.init(*this, MIS_RSP_PORT_NAME, GCFPortInterface::SAP, RSP_PROTOCOL);
-  _daemon.getPortProvider().accept(_missPort);
+	_missPort.init(*this, MAC_SVCMASK_MISSESSION, GCFPortInterface::SPP, MIS_PROTOCOL);
+	_rspDriverPort.init(*this, MAC_SVCMASK_RSPDRIVER, GCFPortInterface::SAP, RSP_PROTOCOL);
+	_daemon.getPortProvider().accept(_missPort);
 }
 
+//
+// ~MISSession()
+//
 MISSession::~MISSession () 
 {
 #if 0
@@ -115,12 +114,14 @@ MISSession::~MISSession ()
 #endif
 }
 
+//
+// initial_state(event, port)
+//
 GCFEvent::TResult MISSession::initial_state(GCFEvent& e, GCFPortInterface& /*p*/)
 {
   GCFEvent::TResult status = GCFEvent::HANDLED;
   
-  switch (e.signal)
-  {
+  switch (e.signal) {
     case F_INIT:
       break;
 
@@ -143,6 +144,9 @@ GCFEvent::TResult MISSession::initial_state(GCFEvent& e, GCFPortInterface& /*p*/
   return status;
 }
 
+//
+// waiting_state(event, port)
+//
 GCFEvent::TResult MISSession::waiting_state(GCFEvent& e, GCFPortInterface& p)
 {
   GCFEvent::TResult status = GCFEvent::HANDLED;
@@ -154,7 +158,7 @@ GCFEvent::TResult MISSession::waiting_state(GCFEvent& e, GCFPortInterface& p)
       _busy = false;
       garbageTimerID = _missPort.setTimer(5.0, 5.0);
       if (_pRememberedEvent) delete _pRememberedEvent;
-      _pRememberedEvent = 0;
+		  _pRememberedEvent = 0;
       break;
 
     case F_EXIT:
@@ -239,6 +243,9 @@ GCFEvent::TResult MISSession::waiting_state(GCFEvent& e, GCFPortInterface& p)
   return status;
 }
 
+//
+// genericPingPong(event)
+//
 void MISSession::genericPingpong(GCFEvent& e)
 {
   MISGenericPingpongEvent in(e);
@@ -252,6 +259,9 @@ void MISSession::genericPingpong(GCFEvent& e)
   _missPort.send(out);
 }
 
+//
+// getGenericIdentity(event)
+//
 void MISSession::getGenericIdentity(GCFEvent& e)
 {    
   MISGenericIdentifyRequestEvent in(e);
@@ -273,94 +283,16 @@ void MISSession::getGenericIdentity(GCFEvent& e)
   _missPort.send(out);
 }
 
+//
+// setDiagnosis(event)
+//
 void MISSession::setDiagnosis(GCFEvent& e)
 {
-#if 0
-  MISDiagnosisNotificationEvent* pIn(0);
-  static string resourceStatusPropName = "";
-
-  assert(_pRememberedEvent == 0);
-    
-  pIn = new MISDiagnosisNotificationEvent(e);
-  LOGMSGHDR((*pIn));
-  resourceStatusPropName = pIn->component;
-
-  // first try to get the current status value of the component
-  // for this purpose it is important that the component name contains ".status"
-  if (resourceStatusPropName.find(".status") == string::npos) {
-    resourceStatusPropName += ".status";
-  }
-  if (GCFPVSSInfo::propExists(resourceStatusPropName)) {
-    if (_propertyProxy.requestPropValue(resourceStatusPropName) != GCF_NO_ERROR) {
-      SEND_RESP_MSG((*pIn), DiagnosisResponse, "NAK (Error while requesting the current component status!)");
-    }
-    else {
-      _pRememberedEvent = pIn;      
-      TRAN(MISSession::setDiagnosis_state);
-    }
-  }
-  else {
-    SEND_RESP_MSG((*pIn), DiagnosisResponse, "NAK (Component has no status or does not exist!)");
-  }
-  if (_pRememberedEvent == 0) {
-    delete pIn;
-  }
-#endif
-}
-
-GCFEvent::TResult MISSession::setDiagnosis_state(GCFEvent& e, GCFPortInterface& p)
-{
-  GCFEvent::TResult status = GCFEvent::HANDLED;
-#if 0
+	MISDiagnosisNotificationEvent	diagnose(e);
 
-  static string resourceStatusPropName = "";
-  
-  switch (e.signal)
-  {
-    case F_VGETRESP:
-    {
-      assert (_pRememberedEvent);
-      MISDiagnosisNotificationEvent* pIn = (MISDiagnosisNotificationEvent*)_pRememberedEvent;
-      resourceStatusPropName = pIn->component;
-      // first try to get the current status value of the component
-      // for this purpose it is important that the component name contains ".status"
-      if (resourceStatusPropName.find(".status") == string::npos)
-      {
-        resourceStatusPropName += ".status";
-      }
+	// setObjectState(message, datapoint, new state)
+	setObjectState("SHM:" + diagnose.diagnosis_id, diagnose.component, diagnose.new_state);
 
-      GCFPVInteger resourceState(RS_IDLE);
-      GCFPropValueEvent* pE = (GCFPropValueEvent*)(&e);
-      resourceState.copy(*pE->pValue); 
-      string response  = _daemon.getPolicyHandler().checkDiagnose(*pIn, resourceState);
-      if (response == "ACK")
-      {
-        _propertyProxy.setPropValue(resourceStatusPropName, resourceState);
-        if (resourceStatusPropName.find(":") == string::npos)
-        {
-          resourceStatusPropName = GCFPVSSInfo::getLocalSystemName() + string(":") + resourceStatusPropName;
-        }
-        timeval ts = {pIn->timestamp_sec, pIn->timestamp_nsec / 1000};
-        string descr(formatString (
-            "%s(cl:%d, url:%d)",
-            pIn->diagnosis.c_str(),
-            pIn->confidence,
-            pIn->diagnosis_id.c_str()));
-        
-        LOG_KEYVALUE_TSD(resourceStatusPropName, resourceState, 
-                         KVL_ORIGIN_SHM, ts, descr);
-      }
-      SEND_RESP_MSG((*pIn), DiagnosisResponse, response);
-      TRAN(MISSession::waiting_state);      
-      break;
-    }  
-      
-    default:
-      status = defaultHandling(e, p);
-      break;
-  }
-#endif
-  return status;
 }
 
 
@@ -474,12 +406,12 @@ void MISSession::getRspStatus(GCFEvent& e)
 		try {
 		  //MAXMOD
 		  //_nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * GET_CONFIG("RS.N_BLPS", i) * MEPHeader::N_POL;
-		  _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * MEPHeader::N_POL;
+		  _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * N_POL;
 		  LOG_DEBUG(formatString ("NrOfRCUs %d", _nrOfRCUs));
 		  _allRCUSMask.reset(); // init all bits to false value
 		  _allRCUSMask.flip(); // flips all bits to the true value
 		  // if nrOfRCUs is less than MAX_N_RCUS the not used bits must be unset
-		  for (int i = _nrOfRCUs; i < MEPHeader::MAX_N_RCUS; i++) {
+		  for (int i = _nrOfRCUs; i < MAX_RCUS; i++) {
 		    _allRCUSMask.set(i, false);
 		  }
 		  // idem for RSP mask [reo]
@@ -611,12 +543,12 @@ void MISSession::getSubbandStatistics(GCFEvent& e)
 		try {
 		  //MAXMOD
 		  //_nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * GET_CONFIG("RS.N_BLPS", i) * MEPHeader::N_POL;
-		  _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * MEPHeader::N_POL;
+		  _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * N_POL;
 			LOG_DEBUG(formatString ("NrOfRCUs %d", _nrOfRCUs));
 			_allRCUSMask.reset(); // init all bits to false value
 			_allRCUSMask.flip(); // flips all bits to the true value
 			// if nrOfRCUs is less than MAX_N_RCUS the not used bits must be unset
-			for (int i = _nrOfRCUs; i < MEPHeader::MAX_N_RCUS; i++) {
+			for (int i = _nrOfRCUs; i < MAX_RCUS; i++) {
 				_allRCUSMask.set(i, false);
 			}
 			// idem for RSP mask [reo]
@@ -812,9 +744,9 @@ void MISSession::getAntennaCorrelation(GCFEvent& e)
 
 	int subband = pIn->subband_selector;
 
-	if (subband < 0 || subband >= MEPHeader::N_SUBBANDS)
+	if (subband < 0 || subband >= MAX_SUBBANDS)
 	  {
-	    LOG_DEBUG(formatString("MAXMOD: Error: argument to --xcsubband out of range, value must be >= 0 and < %d",MEPHeader::N_SUBBANDS));
+	    LOG_DEBUG(formatString("MAXMOD: Error: argument to --xcsubband out of range, value must be >= 0 and < %d",MAX_SUBBANDS));
 	    //exit(EXIT_FAILURE);
 	    TRAN(MISSession::waiting_state);
 	  }
@@ -822,12 +754,12 @@ void MISSession::getAntennaCorrelation(GCFEvent& e)
 	//MAXMOD I'm not sure the following is really nec.
 	if (_nrOfRCUs == 0) {
 	  try {
-	    _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * MEPHeader::N_POL;
+	    _nrOfRCUs = GET_CONFIG("RS.N_RSPBOARDS", i) * 4 * N_POL;
 	    LOG_DEBUG(formatString ("NrOfRCUs %d", _nrOfRCUs));
 	    _allRCUSMask.reset(); // init all bits to false value
 	    _allRCUSMask.flip(); // flips all bits to the true value
 	    // if nrOfRCUs is less than MAX_N_RCUS the not used bits must be unset
-	    for (int i = _nrOfRCUs; i < MEPHeader::MAX_N_RCUS; i++) {
+	    for (int i = _nrOfRCUs; i < MAX_RCUS; i++) {
 	      _allRCUSMask.set(i, false);
 	    }
 	    // idem for RSP mask [reo]
@@ -973,7 +905,7 @@ GCFEvent::TResult MISSession::getAntennaCorrelation_state(GCFEvent& e, GCFPortIn
 
       setsubbands.subbands().resize(1,1);
       list<int> subbandlist;
-      for (int rcu = 0; rcu < _nrOfRCUs / MEPHeader::N_POL; rcu++){
+      for (int rcu = 0; rcu < _nrOfRCUs / N_POL; rcu++){
 	subbandlist.push_back(pIn->subband_selector);
 	LOG_DEBUG(formatString("MAXMOD rcu = %d", rcu));
       }
@@ -1109,7 +1041,7 @@ GCFEvent::TResult MISSession::defaultHandling(GCFEvent& e, GCFPortInterface& p)
       break;
     
     case MIS_DIAGNOSIS_NOTIFICATION:
-      RETURN_NOACK_MSG(DiagnosisNotification, DiagnosisResponse, "BUSY");     
+//      RETURN_NOACK_MSG(DiagnosisNotification, DiagnosisResponse, "BUSY");     
       break;
 
     case MIS_RECONFIGURATION_REQUEST:
@@ -1144,6 +1076,7 @@ GCFEvent::TResult MISSession::defaultHandling(GCFEvent& e, GCFPortInterface& p)
   return status;
 }
 
+#if 0
 void MISSession::subscribed(MISPvssDpSubscriptionResponseEvent& e)
 {
   e.seqnr = _curSeqNr++;
@@ -1156,6 +1089,7 @@ void MISSession::valueChanged(MISPvssDpSubscriptionValueChangedAsyncEvent& e)
   e.seqnr = _curSeqNr++;
   _missPort.send(e);
 }
+#endif 
 
 void MISSession::mayDelete(const string& propName)
 {
diff --git a/MAC/APL/PIC/MIS/src/MISSession.h b/MAC/APL/PIC/MIS/src/MISSession.h
index 49f9c0dd1e8..6a8ec633476 100644
--- a/MAC/APL/PIC/MIS/src/MISSession.h
+++ b/MAC/APL/PIC/MIS/src/MISSession.h
@@ -33,15 +33,13 @@
 #include <MIS_Protocol.ph>
 #include <APL/RSP_Protocol/RSP_Protocol.ph>
 
-namespace blitz
-{
- template<typename, int > class Array;
+namespace blitz {
+	template<typename, int > class Array;
 }
-namespace LOFAR 
-{
- using MACIO::GCFEvent;
- namespace AMI
- {  
+
+namespace LOFAR {
+	using MACIO::GCFEvent;
+	namespace AMI {  
 
 class MISDaemon;
 //class MISSubsciption;
@@ -50,17 +48,18 @@ class MISDaemon;
 
 class MISSession : public GCF::TM::GCFTask
 {
-  public:
+public:
     MISSession (MISDaemon& daemon);
     virtual ~MISSession ();
     
-  public: // member functions
-    void subscribed(MISPvssDpSubscriptionResponseEvent& e);
-    void valueChanged(MISPvssDpSubscriptionValueChangedAsyncEvent& e);
+	// member functions
+//    void subscribed(MISPvssDpSubscriptionResponseEvent& e);
+//    void valueChanged(MISPvssDpSubscriptionValueChangedAsyncEvent& e);
     void mayDelete(const string& propName);
     static void setCurrentTime(int64& sec, uint32& nsec);
   
-  private: // state methods
+private: 
+	// state methods
     GCFEvent::TResult initial_state                (GCFEvent& e, GCF::TM::GCFPortInterface& p);
     GCFEvent::TResult waiting_state                (GCFEvent& e, GCF::TM::GCFPortInterface& p);
     GCFEvent::TResult setDiagnosis_state           (GCFEvent& e, GCF::TM::GCFPortInterface& p);
@@ -74,7 +73,7 @@ class MISSession : public GCF::TM::GCFTask
         
     GCFEvent::TResult defaultHandling              (GCFEvent& e, GCF::TM::GCFPortInterface& p);
 
-  private: // helper methods
+	// helper methods
     void genericPingpong      (GCFEvent& e);
     void getGenericIdentity   (GCFEvent& e);
     void setDiagnosis         (GCFEvent& e);
@@ -83,7 +82,8 @@ class MISSession : public GCF::TM::GCFTask
     //MAXMOD
     void getAntennaCorrelation(GCFEvent& e);
     void getRspStatus         (GCFEvent& e);
-  private: // data members      
+
+	// data members      
 //    typedef map<string /*resource name*/, MISSubscription*> TSubscriptions;
     GCF::TM::GCFTCPPort _missPort;
     GCF::TM::GCFTCPPort _rspDriverPort;
@@ -92,7 +92,7 @@ class MISSession : public GCF::TM::GCFTask
 //    TSubscriptions      _subscriptions;
 //    PropertyProxy       _propertyProxy;
 
-  private: // admin members
+	// admin members
     uint64                  _curSeqNr;
     uint64                  _curReplyNr;
     bool                    _busy;
@@ -102,6 +102,7 @@ class MISSession : public GCF::TM::GCFTask
     bitset<MEPHeader::MAX_N_RCUS> _allRCUSMask;    
     bitset<MAX_N_RSPBOARDS> _allRSPSMask;    
 };
+
  } // namespace AMI
 } // namespace LOFAR
 
diff --git a/MAC/APL/PIC/MIS/src/MIS_Protocol.prot b/MAC/APL/PIC/MIS/src/MIS_Protocol.prot
index a9fa3e238c3..ce83f44aa6f 100644
--- a/MAC/APL/PIC/MIS/src/MIS_Protocol.prot
+++ b/MAC/APL/PIC/MIS/src/MIS_Protocol.prot
@@ -206,45 +206,22 @@ event = {
 event = {
     signal = "DIAGNOSIS_NOTIFICATION";
     dir = IN; // SHM -> MAC
-    param = {
-        name = "seqnr";
-        type = "uint64";
-    };
-    param = {
-        name = "replynr"; // always zero
-        type = "uint64";
-    };
     param = {
         name = "timestamp_sec";
         type = "int64";
     };
-    param = {
-        name = "timestamp_nsec";
-        type = "uint32";
-    };
-    // The payload timestamp denotes the time for which the diagnosis
-    // being reported is "valid". This may be taken into account by
-    // the diagnosis policy (e.g., reject diagnoses that are too old).
-    param = {
-        name = "payload_timestamp_sec";
-        type = "int64";
-    };
-    param = {
-        name = "payload_timestamp_nsec";
-        type = "uint32";
-    };
+
     // PVSS property set name of the component being diagnosed.
     param = {
         name = "component";  // e.g. "PIC_Rack0_SubRack0_Board0_AP0_RCU0_HFA"
         type = "string";
     };
-    // Format: <FAULTHY|HEALTHY> [(explanation)]"
-    // e.g.: "FAULTY (broken fuse)"
-    //       "HEALTHY"
+
     param = {
-        name = "diagnosis";
-        type = "string";
+        name = "new_state";
+        type = "int64";
     };
+
     // Confidence of SHM in its own diagnosis.
     // range: 0 (absolutely unsure) to 10000 (absolutely sure).
     //
@@ -264,6 +241,7 @@ event = {
         name = "confidence";
         type = "uint16";
     };
+
     // The diagnosis_id can be used to get an explanation URI,
     // e.g. "diag1003" --> "http://shm.lofar/diagnosis-info?diagnosis_id=diag1003".
     // The way in which the diagnosis_id can be translated to a URI
diff --git a/MAC/APL/PIC/MIS/src/Makefile.am b/MAC/APL/PIC/MIS/src/Makefile.am
index e119869c56a..70d7fb02edc 100644
--- a/MAC/APL/PIC/MIS/src/Makefile.am
+++ b/MAC/APL/PIC/MIS/src/Makefile.am
@@ -10,7 +10,6 @@ DOCHDRS	=	 $(BUILT_SOURCES) \
 	MISDaemon.h \
 	MISDefines.h \
 	MISSession.h \
-	MISPolicyHandler.h \
 	XCStatistics.h \
 	RspStatus.h
 
@@ -23,7 +22,6 @@ libmis_la_SOURCES	= Package__Version.cc \
 	$(DOCHDRS) \
 	MISDaemon.cc \
 	MISSession.cc \
-	MISPolicyHandler.cc \
 	MIS_Protocol.cc \
 	XCStatistics.cc \
 	RspStatus.cc
@@ -42,8 +40,7 @@ BUILT_SOURCES = \
 
 EXTRA_DIST = $(sysconf_DATA)
 	
-sysconf_DATA= \
-	MACInformationServer.conf
+sysconf_DATA= 
 	
 %.conf: %.conf.in
 	cp $< $@
-- 
GitLab