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
This commit is contained in:
Ferdi Franceschini
2011-09-23 08:49:00 +10:00
committed by Douglas Clowes
parent c765c33f6d
commit d778dd2bfe
7 changed files with 37 additions and 21 deletions

View File

@@ -395,6 +395,10 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
{ {
handleMoveCallback(self,pCon); handleMoveCallback(self,pCon);
} }
if(status == HWFault) {
SCSetInterrupt(pCon,eAbortBatch);
}
return status; return status;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@@ -703,9 +703,11 @@ int SCWriteJSON_String(SConnection *pCon, char *pBuffer, int iOut)
{ {
iRet = 0; iRet = 0;
} }
sprintf(pBueffel,"Next line intended for socket: %d",iRet); if(pCon->iMacro != 1) {
SICSLogWrite(pBueffel,eInternal); sprintf(pBueffel,"Next line intended for socket: %d",iRet);
SICSLogWrite(pBuffer,iOut); SICSLogWrite(pBueffel,eInternal);
SICSLogWrite(pBuffer,iOut);
}
/* write to commandlog if user or manager privilege */ /* write to commandlog if user or manager privilege */
if(SCGetRights(pCon) <= usUser) if(SCGetRights(pCon) <= usUser)

View File

@@ -339,13 +339,14 @@ typedef struct {
int internalID; int internalID;
}HdbCBInfo; }HdbCBInfo;
static Protocol isJSON(SConnection *pCon) { static Protocol isJSON(SConnection *pCon, int notify) {
char proName[128]; char proName[128];
void *pData; void *pData;
if(SCinMacro(pCon)){ if(notify == 0 && SCinMacro(pCon)){
return normal_protocol; return normal_protocol;
} }
pData = FindCommandData(pServ->pSics, "protocol","Protocol"); pData = FindCommandData(pServ->pSics, "protocol","Protocol");
ProtocolGet(pCon, pData, proName, 128); ProtocolGet(pCon, pData, proName, 128);
if (strcmp(proName, "json") == 0) if (strcmp(proName, "json") == 0)
@@ -537,7 +538,7 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData,
pPath = GetHipadabaPath(node); pPath = GetHipadabaPath(node);
result = CreateDynString(128,128); result = CreateDynString(128,128);
if ((protocol = isJSON(cbInfo->pCon)) == 1) if ((protocol = isJSON(cbInfo->pCon, 1)) == 1)
outCode = eHdbEvent; outCode = eHdbEvent;
else else
outCode = eEvent; outCode = eEvent;
@@ -654,7 +655,7 @@ static hdbCallbackReturn TreeChangeCallback(pHdb node, void *userData,
return hdbAbort; return hdbAbort;
} }
path = GetHipadabaPath(node); path = GetHipadabaPath(node);
if ((protocol = isJSON(cbInfo->pCon)) == 1) if ((protocol = isJSON(cbInfo->pCon, 1)) == 1)
outCode = eHdbEvent; outCode = eHdbEvent;
else else
outCode = eEvent; outCode = eEvent;
@@ -2344,7 +2345,7 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,"ERROR: out of memory formatting data",eError); SCWrite(pCon,"ERROR: out of memory formatting data",eError);
return 0; return 0;
} }
if ((protocol = isJSON(pCon)) == 1) if ((protocol = isJSON(pCon, 0)) == 1)
outCode = eHdbEvent; outCode = eHdbEvent;
else else
outCode = eEvent; outCode = eEvent;
@@ -2386,7 +2387,7 @@ static int GetHdbVal(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,"ERROR: out of memory formatting data",eError); SCWrite(pCon,"ERROR: out of memory formatting data",eError);
return 0; return 0;
} else { } else {
if ((protocol = isJSON(pCon)) == 1) if ((protocol = isJSON(pCon, 0)) == 1)
outCode = eHdbEvent; outCode = eHdbEvent;
else else
outCode = eEvent; outCode = eEvent;
@@ -2672,7 +2673,7 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
} else if(strcmp(argv[1],"-cli") == 0){ } else if(strcmp(argv[1],"-cli") == 0){
listData = formatClientList(node); listData = formatClientList(node);
} else { } else {
if ((protocol = isJSON(pCon)) == 1) { if ((protocol = isJSON(pCon, 0)) == 1) {
listData = formatJSONList(node); listData = formatJSONList(node);
outCode = eHdbEvent; outCode = eHdbEvent;
} else { } else {

View File

@@ -173,7 +173,6 @@ proc ::histogram_memory::hmm_set_read_type {type} {
set hmm_ext [select_read_type $type] set hmm_ext [select_read_type $type]
} }
$HMOBJ configure hmm_ext $hmm_ext $HMOBJ configure hmm_ext $hmm_ext
$HMOBJ init
} msg ] { } msg ] {
return -code error "([info level 0]) $msg" return -code error "([info level 0]) $msg"
} }

View File

@@ -861,6 +861,7 @@ proc ::nexus::histmem::save {hm nxalias hpath data_type filestatus args} {
} elseif { $max_period > 0} { } elseif { $max_period > 0} {
$HMOBJ configure read_data_period_number $point $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 nxscript putslab $nxalias [join [list $point $hmmslabstart ]] [join [list 1 $hmmslabend]] $HMOBJ 0 $datsize 1
##### #####
if {$filestatus == "newfile"} { if {$filestatus == "newfile"} {

View File

@@ -233,6 +233,8 @@ proc server_set_sobj_attributes {} {
} }
proc server_init {} { proc server_init {} {
global AUTOSAVE_STATE
set catch_status [ catch { set catch_status [ catch {
::source::isc_initialize ::source::isc_initialize
::counter::isc_initialize ::counter::isc_initialize
@@ -259,8 +261,7 @@ proc server_init {} {
sicslist setatt sics_suid nxsave true sicslist setatt sics_suid nxsave true
sicslist setatt sics_suid long_name sics_suid sicslist setatt sics_suid long_name sics_suid
VarMake AUTOSAVE_STATE Text user set AUTOSAVE_STATE "DISABLED"
AUTOSAVE_STATE "DISABLED"
if [file exists ../extraconfig.tcl] { if [file exists ../extraconfig.tcl] {
fileeval ../extraconfig.tcl fileeval ../extraconfig.tcl
@@ -273,8 +274,10 @@ proc server_init {} {
} }
proc doAutosave {} { proc doAutosave {} {
global AUTOSAVE_STATE
# Reset the AUTOSAVE_STATE variable in case some naughty user sets it directly # 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 HMSTATE [SplitReply [hmm configure daq]]
set FSTATE [SplitReply [file_status]] set FSTATE [SplitReply [file_status]]
#broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE #broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE
@@ -286,20 +289,25 @@ proc doAutosave {} {
} }
publish doAutosave user publish doAutosave user
proc autosave { {interval 300} } { proc autosave { {interval 300} } {
set stateVal [SplitReply [AUTOSAVE_STATE]] global AUTOSAVE_STATE
if {$interval == "check"} { 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]} { } elseif {[string is integer $interval]} {
if {$interval <= 0} { if {$interval <= 0} {
if { $stateVal == "ENABLED" } { if { $AUTOSAVE_STATE == "ENABLED" } {
sicspoll del doAutosave sicspoll del doAutosave
AUTOSAVE_STATE "DISABLED" set AUTOSAVE_STATE "DISABLED"
} }
} else { } else {
if {$stateVal == "DISABLED"} { if {$AUTOSAVE_STATE == "DISABLED"} {
sicspoll add doAutosave script $interval doAutosave sicspoll add doAutosave script $interval doAutosave
sicspoll listen # sicspoll listen # WARNING:When the listening client exits it leaves SICSPOLL task with a corrupt connection object.
AUTOSAVE_STATE "ENABLED" set AUTOSAVE_STATE "ENABLED"
} else { } else {
sicspoll intervall doAutosave $interval sicspoll intervall doAutosave $interval
} }

View File

@@ -2655,6 +2655,7 @@ static void DMCState_Error(pDMC2280Driv self, pEvtEvent event) {
break; break;
} }
unhandled_event(self, event); unhandled_event(self, event);
self->driver_status = HWFault;
self->errorCode = STATEERROR; self->errorCode = STATEERROR;
return; return;
} }