From d778dd2bfed3fbceb99dbac78fb18ffb4b084f2a Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 23 Sep 2011 08:49:00 +1000 Subject: [PATCH] sicshipacaba.c SICS-418 Make sure hnotify sends messages as hdbevents when using the JSON protocl site_ansto/instrument/config/hmm/hmm_object.tcl Initialise the hmm object to make sure the read type is set. nxscripts_common_1.tcl Set the read type when saving the hmm data. server_config.tcl Fix the autosave command so that you can enable/disable autosave while the histogram memory is running. protocol.c Reduce noise in log files when using the JSON protocol. Don't log messages generated during macro execution (ie within a TCL proc). motor.c:MotorStatus Abort the current operation, the scan command and batch files when a motor object returns a hardware fault status value. motor_dmc2280.c set driver status to HWFault when the driver is in the error state. r3251 | ffr | 2011-09-23 08:49:00 +1000 (Fri, 23 Sep 2011) | 25 lines --- motor.c | 4 +++ protocol.c | 8 ++++-- sicshipadaba.c | 15 +++++----- .../instrument/config/hmm/hmm_object.tcl | 1 - .../config/nexus/nxscripts_common_1.tcl | 1 + site_ansto/instrument/server_config.tcl | 28 ++++++++++++------- site_ansto/motor_dmc2280.c | 1 + 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/motor.c b/motor.c index d410e44f..c8cf487f 100644 --- a/motor.c +++ b/motor.c @@ -395,6 +395,10 @@ static void handleMoveCallback(pMotor self, SConnection *pCon) { handleMoveCallback(self,pCon); } + if(status == HWFault) { + SCSetInterrupt(pCon,eAbortBatch); + } + return status; } /*---------------------------------------------------------------------------*/ diff --git a/protocol.c b/protocol.c index 909ac1ca..23f83873 100644 --- a/protocol.c +++ b/protocol.c @@ -703,9 +703,11 @@ int SCWriteJSON_String(SConnection *pCon, char *pBuffer, int iOut) { iRet = 0; } - sprintf(pBueffel,"Next line intended for socket: %d",iRet); - SICSLogWrite(pBueffel,eInternal); - SICSLogWrite(pBuffer,iOut); + if(pCon->iMacro != 1) { + sprintf(pBueffel,"Next line intended for socket: %d",iRet); + SICSLogWrite(pBueffel,eInternal); + SICSLogWrite(pBuffer,iOut); + } /* write to commandlog if user or manager privilege */ if(SCGetRights(pCon) <= usUser) diff --git a/sicshipadaba.c b/sicshipadaba.c index 877747ef..8f3925f6 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -339,13 +339,14 @@ typedef struct { int internalID; }HdbCBInfo; -static Protocol isJSON(SConnection *pCon) { +static Protocol isJSON(SConnection *pCon, int notify) { char proName[128]; void *pData; - if(SCinMacro(pCon)){ + if(notify == 0 && SCinMacro(pCon)){ return normal_protocol; } + pData = FindCommandData(pServ->pSics, "protocol","Protocol"); ProtocolGet(pCon, pData, proName, 128); if (strcmp(proName, "json") == 0) @@ -537,7 +538,7 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData, pPath = GetHipadabaPath(node); result = CreateDynString(128,128); - if ((protocol = isJSON(cbInfo->pCon)) == 1) + if ((protocol = isJSON(cbInfo->pCon, 1)) == 1) outCode = eHdbEvent; else outCode = eEvent; @@ -654,7 +655,7 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData, return hdbAbort; } path = GetHipadabaPath(node); - if ((protocol = isJSON(cbInfo->pCon)) == 1) + if ((protocol = isJSON(cbInfo->pCon, 1)) == 1) outCode = eHdbEvent; else outCode = eEvent; @@ -2344,7 +2345,7 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData, SCWrite(pCon,"ERROR: out of memory formatting data",eError); return 0; } - if ((protocol = isJSON(pCon)) == 1) + if ((protocol = isJSON(pCon, 0)) == 1) outCode = eHdbEvent; else outCode = eEvent; @@ -2386,7 +2387,7 @@ static int GetHdbVal(SConnection *pCon, SicsInterp *pSics, void *pData, SCWrite(pCon,"ERROR: out of memory formatting data",eError); return 0; } else { - if ((protocol = isJSON(pCon)) == 1) + if ((protocol = isJSON(pCon, 0)) == 1) outCode = eHdbEvent; else outCode = eEvent; @@ -2672,7 +2673,7 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData, } else if(strcmp(argv[1],"-cli") == 0){ listData = formatClientList(node); } else { - if ((protocol = isJSON(pCon)) == 1) { + if ((protocol = isJSON(pCon, 0)) == 1) { listData = formatJSONList(node); outCode = eHdbEvent; } else { diff --git a/site_ansto/instrument/config/hmm/hmm_object.tcl b/site_ansto/instrument/config/hmm/hmm_object.tcl index 3b31898d..e418df35 100644 --- a/site_ansto/instrument/config/hmm/hmm_object.tcl +++ b/site_ansto/instrument/config/hmm/hmm_object.tcl @@ -173,7 +173,6 @@ proc ::histogram_memory::hmm_set_read_type {type} { set hmm_ext [select_read_type $type] } $HMOBJ configure hmm_ext $hmm_ext - $HMOBJ init } msg ] { return -code error "([info level 0]) $msg" } diff --git a/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl b/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl index cfb835a9..bbb2e5e9 100644 --- a/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl +++ b/site_ansto/instrument/config/nexus/nxscripts_common_1.tcl @@ -861,6 +861,7 @@ proc ::nexus::histmem::save {hm nxalias hpath data_type filestatus args} { } elseif { $max_period > 0} { $HMOBJ configure read_data_period_number $point } + ::histogram_memory::hmm_set_read_type [hgetpropval $::histogram_memory::HP_HMM datatype_savelist] nxscript putslab $nxalias [join [list $point $hmmslabstart ]] [join [list 1 $hmmslabend]] $HMOBJ 0 $datsize 1 ##### if {$filestatus == "newfile"} { diff --git a/site_ansto/instrument/server_config.tcl b/site_ansto/instrument/server_config.tcl index 5e06e12f..623c2214 100644 --- a/site_ansto/instrument/server_config.tcl +++ b/site_ansto/instrument/server_config.tcl @@ -233,6 +233,8 @@ proc server_set_sobj_attributes {} { } proc server_init {} { + global AUTOSAVE_STATE + set catch_status [ catch { ::source::isc_initialize ::counter::isc_initialize @@ -259,8 +261,7 @@ proc server_init {} { sicslist setatt sics_suid nxsave true sicslist setatt sics_suid long_name sics_suid - VarMake AUTOSAVE_STATE Text user - AUTOSAVE_STATE "DISABLED" + set AUTOSAVE_STATE "DISABLED" if [file exists ../extraconfig.tcl] { fileeval ../extraconfig.tcl @@ -273,8 +274,10 @@ proc server_init {} { } proc doAutosave {} { + global AUTOSAVE_STATE + # Reset the AUTOSAVE_STATE variable in case some naughty user sets it directly - AUTOSAVE_STATE "ENABLED" + set AUTOSAVE_STATE "ENABLED" set HMSTATE [SplitReply [hmm configure daq]] set FSTATE [SplitReply [file_status]] #broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE @@ -286,20 +289,25 @@ proc doAutosave {} { } publish doAutosave user proc autosave { {interval 300} } { - set stateVal [SplitReply [AUTOSAVE_STATE]] + global AUTOSAVE_STATE + if {$interval == "check"} { - return [AUTOSAVE_STATE] + if { $AUTOSAVE_STATE == "ENABLED" } { + return "AUTOSAVE $AUTOSAVE_STATE [sicspoll intervall doAutosave]" + } else { + return "AUTOSAVE $AUTOSAVE_STATE" + } } elseif {[string is integer $interval]} { if {$interval <= 0} { - if { $stateVal == "ENABLED" } { + if { $AUTOSAVE_STATE == "ENABLED" } { sicspoll del doAutosave - AUTOSAVE_STATE "DISABLED" + set AUTOSAVE_STATE "DISABLED" } } else { - if {$stateVal == "DISABLED"} { + if {$AUTOSAVE_STATE == "DISABLED"} { sicspoll add doAutosave script $interval doAutosave - sicspoll listen - AUTOSAVE_STATE "ENABLED" +# sicspoll listen # WARNING:When the listening client exits it leaves SICSPOLL task with a corrupt connection object. + set AUTOSAVE_STATE "ENABLED" } else { sicspoll intervall doAutosave $interval } diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 734782e7..c79a7730 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -2655,6 +2655,7 @@ static void DMCState_Error(pDMC2280Driv self, pEvtEvent event) { break; } unhandled_event(self, event); + self->driver_status = HWFault; self->errorCode = STATEERROR; return; }