diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 00000000..d60c31a9 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/amortest.tcl b/amortest.tcl index 49cbc0de..b09fc1d2 100644 --- a/amortest.tcl +++ b/amortest.tcl @@ -266,3 +266,93 @@ source amorpar.tcl Publish amorpar Spy ClientPut "Done Initializing" + +scriptcallback connect xxxscan SCANSTART scanmode +scriptcallback connect hm COUNTSTART tofmode +sicsdatafactory new wwwdata + +Publish getmode Spy +Publish wwwgetdata Spy +Publish wwwsics Spy +Publish wwwgetaxis Spy + +#----------------------------------------------------------------- +set mode 0 +proc tofmode {} { + global mode + set mode 1 +} +#--------------------------------------------------------------------- +proc scanmode {} { + global mode + set mode 0 +} +#------------------------------------------------------------------ +proc getmode {} { + global mode + return $mode +} +#-------------------------------------------------------------------- +proc wwwgetdata {} { + global mode + if {$mode == 1} { + wwwtofdata + } else { + wwwscandata + } + wwwdata writeuu wwwdata +} +#--------------------------------------------------------------------- +proc wwwscandata {} { + wwwdata clear + set np [string trim [SplitReply [xxxscan np]]] + wwwdata putint 0 $np + if {$np > 0} { + wwwdata copyscanvar 1 xxxscan 0 + wwwdata copyscancounts [expr $np + 1] xxxscan + wwwdata copyscanmon [expr $np*2 + 1] xxxscan 2 + } +} +#---------------------------------------------------------------------- +proc wwwtofdata {} { + wwwdata clear + set ntime [string trim [SplitReply [hm notimebin]]] + set dim0 [string trim [SplitReply [hm configure dim0]]] + set dim1 [string trim [SplitReply [hm configure dim1]]] + wwwdata putint 0 $ntime + wwwdata copytimebin 1 hm + set start [expr $dim0*$dim1*$ntime] + set end [expr $start + 2*$ntime] + wwwdata copyhm [expr $ntime + 1] hm $start $end +} +#--------------------------------------------------------------------------- +proc wwwsics {} { + global mode + append result "\n" + append result "\n" + append result "\n" + append result "\n" + append result "\n" + append result "
User " [SplitReply [user]] "
Title " + append result [SplitReply [title]] "
Status " + append result [SplitReply [status]] "
Mode" + if {$mode == 1} { + append result "time-of-flight" + } else { + append result "scan mode" + } + append result "
\n" +} +#------------------------------------------------------------------------- +proc wwwgetaxis {} { + global mode + if {$mode == 1} { + return time-of-flight + } else { + set res [scan info] + set l [split $res ,] + return [lindex $l 2] + } +} + + diff --git a/callback.c b/callback.c index 234a210b..e1c59d30 100644 --- a/callback.c +++ b/callback.c @@ -6,6 +6,8 @@ in file interface.h, interface.w and interface.w. Mark Koennecke, Juli 1997 + + Added ScriptCallback, Mark Koennecke, June 2003 Copyright: @@ -40,9 +42,12 @@ #include #include #include +#include #include "fortify.h" #include "lld.h" #include "sics.h" +#include "macro.h" + #define CALLBACK 17777 @@ -225,3 +230,141 @@ } return 1; } +/*------------------------------------------------------------------- + a write function for the connection which writes to stdout + -------------------------------------------------------------------*/ +static int CallbackWrite(SConnection *pCon,char *message, int outCode) +{ + if(outCode >= eWarning) + { + fputs(message,stdout); + fputs("\n",stdout); + } + return 1; +} +/*----------------------------------------------------------------------- + the actual callback function invoking the script + ------------------------------------------------------------------------*/ +static int ScriptCallback(int iEvent, void *pEventData, void *pUserData) +{ + SConnection *pCon = NULL; + Tcl_Interp *pTcl; + int status; + + pCon = SCCreateDummyConnection(pServ->pSics); + if(!pCon) + { + fprintf(stdout,"ERROR: failed to create dummy connection\n"); + return 0; + } + if(pUserData == NULL) + { + fprintf(stdout,"ERROR: ScriptCallback: no script to execute\n"); + return 0; + } + SCSetWriteFunc(pCon,CallbackWrite); + MacroPush(pCon); + pTcl = InterpGetTcl(pServ->pSics); + status = Tcl_GlobalEval(pTcl,(char *)pUserData); + if(status != TCL_OK) + { + fprintf(stdout,"ERROR: in CallbackScript: %s\n",(char *)pUserData); + fprintf(stdout,"Tcl-error: %s\n",pTcl->result); + } + MacroPop(); + SCDeleteConnection(pCon); + return 1; +} +/*------------------------------------------------------------------------*/ +int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]) +{ + long lID; + int iEvent, status; + pICallBack pCall = NULL; + CommandList *pCom = NULL; + char pBuffer[132]; + + if(argc < 2) + { + SCWrite(pCon,"ERROR: insufficient number of arguments to callbackScript", + eError); + return 0; + } + /* + only managers may do this + */ + if(!SCMatchRights(pCon,usMugger)) + { + return 0; + } + + strtolower(argv[1]); + if(strcmp(argv[1],"connect") == 0) + { + if(argc < 5) + { + SCWrite(pCon,"ERROR: not enough arguments to CallbackScript connect", + eError); + return 0; + } + strtolower(argv[2]); + pCom = FindCommand(pSics,argv[2]); + if(!pCom) + { + SCWrite(pCon,"ERROR: object to connect to not found",eError); + return 0; + } + pCall = GetCallbackInterface(pCom->pData); + if(!pCall) + { + SCWrite(pCon,"ERROR: object has no callback interface",eError); + return 0; + } + iEvent = Text2Event(argv[3]); + if(iEvent < 0) + { + SCWrite(pCon,"ERROR: event type not known",eError); + return 0; + } + lID = RegisterCallback(pCall,iEvent,ScriptCallback, + strdup(argv[4]),free); + sprintf(pBuffer,"callback = %ld", lID); + SCWrite(pCon,pBuffer,eValue); + return 1; + } + else if(strcmp(argv[1],"remove") == 0) + { + if(argc < 4) + { + SCWrite(pCon,"ERROR: not enough arguments to CallbackScript remove", + eError); + return 0; + } + strtolower(argv[2]); + pCom = FindCommand(pSics,argv[2]); + if(!pCom) + { + SCWrite(pCon,"ERROR: object to remove to not found",eError); + return 0; + } + pCall = GetCallbackInterface(pCom->pData); + if(!pCall) + { + SCWrite(pCon,"ERROR: object has no callback interface",eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[3],&iEvent); + if(status != TCL_OK) + { + SCWrite(pCon,"ERROR: failed to convert callback ID to int",eError); + return 0; + } + RemoveCallback(pCall,(long)iEvent); + SCSendOK(pCon); + return 1; + } + + SCWrite(pCon,"ERROR: subcommand to CallbackScript not known",eError); + return 0; +} diff --git a/danu.dat b/danu.dat index d3302f46..a8179996 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 279 + 286 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/event.c b/event.c index 5ec46c55..707304b6 100644 --- a/event.c +++ b/event.c @@ -41,12 +41,25 @@ #include "fortify.h" #include "event.h" +/* + WATCHIT! see event.h for defines of event codes! The list below MUST + match. +*/ static char *pEvent[] = { "VARCHANGE", "MOTORDRIVE", "MONITOR", "ROTORSTART", "ROTORMOVE", + "SCANEND", + "SCANSTART", + "SCANPOINT", + "WLCHANGE", + "REFLECTIONDONE", + "COUNTSTART", + "COUNTEND", + "FILELOADED", + "MOTEND", NULL }; @@ -65,3 +78,5 @@ } return -1; } + + diff --git a/event.h b/event.h index 27a547d8..72d02790 100644 --- a/event.h +++ b/event.h @@ -26,7 +26,6 @@ #define VALUECHANGE 0 #define MOTDRIVE 1 -#define MOTEND 13 #define MONITOR 2 #define ROTSTART 3 #define ROTMOVE 4 @@ -38,6 +37,7 @@ #define COUNTSTART 10 #define COUNTEND 11 #define FILELOADED 12 +#define MOTEND 13 #line 92 "event.w" diff --git a/gpibcontroller.c b/gpibcontroller.c index 0158da55..cff8c1f2 100644 --- a/gpibcontroller.c +++ b/gpibcontroller.c @@ -105,7 +105,7 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]){ pGPIB self = (pGPIB)pData; int boardID, devID, tmo, count, eoi, eot, address, - secondaryAddress, status, terminator; + secondaryAddress, status, terminator, value; char pBuffer[1024]; char *result = NULL; @@ -267,10 +267,36 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData, SCWrite(pCon,pBuffer,eValue); return 1; } else { - sprintf(pBuffer,"ERROR: error %d on send", status); + sprintf(pBuffer,"ERROR: error %d on read", status); SCWrite(pCon,pBuffer,eError); return 0; } + } else if(strcmp(argv[1],"readnum") == 0){ + /* + readnum command + */ + if(argc < 2){ + SCWrite(pCon,"ERROR: insufficient number of arguments to read", + eError); + return 0; + } + if(Tcl_GetInt(pSics->pTcl,argv[2],&devID) != TCL_OK){ + SCWrite(pCon,"ERROR: failed to convert arguments to integer", + eError); + return 0; + } + status = GPIBread(self,devID,&value, 4); + if(status > 0){ + sprintf(pBuffer,"gpib %d = %d",devID,value); + SCWrite(pCon,pBuffer,eValue); + return 1; + } else { + /* + sprintf(pBuffer,"ERROR: error %d on read", status); + SCWrite(pCon,pBuffer,eError); + */ + return 0; + } } else if(strcmp(argv[1],"readtillterm") == 0){ /* read command diff --git a/hardsup/sinqhm.c b/hardsup/sinqhm.c index fe2c878e..2130591e 100644 --- a/hardsup/sinqhm.c +++ b/hardsup/sinqhm.c @@ -1254,8 +1254,11 @@ extern int close(int fp); /* done */ return 1; } -/*------------------------------------------------------------------------*/ - int SINQHMZero(pSINQHM self, int iNumber, int iStart, int iEnd) +/*------------------------------------------------------------------------ + This is the old version, using a master socjet, delete if the other version + with client socket works alright. +*/ + int SINQHMZero2(pSINQHM self, int iNumber, int iStart, int iEnd) { int status, iRet; struct req_buff_struct Req_buff; @@ -1303,6 +1306,55 @@ extern int close(int fp); } return 1; /* success, finally */ } +/*-----------------------------------------------------------------------*/ + int SINQHMZero(pSINQHM self, int iNumber, int iStart, int iEnd) + { + int status, iRet; + struct req_buff_struct Req_buff; + struct rply_buff_struct Rply_buff; + + assert(self); + + /* fill in the request data structure */ + Req_buff.bigend = htonl (0x12345678); + Req_buff.cmnd = htonl (SQHM_ZERO); + Req_buff.u.zero.hist_no = htonl (iNumber); + Req_buff.u.zero.first_bin = htonl (iStart); + Req_buff.u.zero.n_bins = htonl (iEnd); + + /* send request */ + status = send(self->iClientSocket,(char *)&Req_buff, sizeof(Req_buff),0); + if(status == -1) + { + return SEND_ERROR; + } + if(status != sizeof(Req_buff)) + { + return SEND_ERROR; + } + + /* get a reply */ + iRet = recv(self->iClientSocket,(char *)&Rply_buff,sizeof(Rply_buff), + MSG_WAITALL); + if(iRet < 0) + { + return RECEIVE_ERROR; + } + if(iRet != sizeof(Rply_buff)) + { + return INSUFFICIENT_DATA; + } + if(ntohl (Rply_buff.bigend) != 0x12345678) + { + return BYTE_ORDER_CHAOS; + } + iRet = ntohl(Rply_buff.status); + if(iRet != KER__SUCCESS) + { + return HIST_BAD_CODE; + } + return 1; /* success, finally */ + } /*------------------------------------------------------------------------*/ static int OpenMasterConnection(pSINQHM self) diff --git a/interface.c b/interface.c index 5663fdda..6435c46c 100644 --- a/interface.c +++ b/interface.c @@ -113,4 +113,10 @@ { return (pICountable)FindInterface(pObject,COUNTID); } - +/*--------------------------------------------------------------------------*/ + pICallBack GetCallbackInterface(void *pObject) + { + return (pICallBack)FindInterface(pObject,CALLBACKINTERFACE); + } + + diff --git a/interface.h b/interface.h index b501949f..9065ba91 100644 --- a/interface.h +++ b/interface.h @@ -1,5 +1,5 @@ -#line 346 "interface.w" +#line 359 "interface.w" /*--------------------------------------------------------------------------- I N T E R F A C E S @@ -44,7 +44,7 @@ pIDrivable GetDrivableInterface(void *pObject); -#line 371 "interface.w" +#line 384 "interface.w" pIDrivable CreateDrivableInterface(void); @@ -68,7 +68,7 @@ pICountable GetCountableInterface(void *pObject); -#line 376 "interface.w" +#line 389 "interface.w" pICountable CreateCountableInterface(void); @@ -81,7 +81,7 @@ typedef int (*SICSCallBack)(int iEvent, void *pEventData, void *pUserData); -#line 381 "interface.w" +#line 394 "interface.w" #line 252 "interface.w" @@ -99,11 +99,16 @@ int RemoveCallback(pICallBack pInterface, long iID); int RemoveCallback2(pICallBack pInterface, void *pUserData); -#line 382 "interface.w" + int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]); + + pICallBack GetCallbackInterface(void *pData); + +#line 395 "interface.w" /*---------------------- The Environment Interface --------------------*/ -#line 310 "interface.w" +#line 323 "interface.w" typedef enum { EVIdle, EVDrive, EVMonitor, EVError } EVMode; typedef struct { @@ -113,13 +118,13 @@ int (*HandleError)(void *self); } EVInterface, *pEVInterface; -#line 384 "interface.w" +#line 397 "interface.w" -#line 336 "interface.w" +#line 349 "interface.w" pEVInterface CreateEVInterface(void); -#line 385 "interface.w" +#line 398 "interface.w" #endif diff --git a/interface.tex b/interface.tex index a21afda1..4919c407 100644 --- a/interface.tex +++ b/interface.tex @@ -316,6 +316,11 @@ $\langle$cifunc {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ void *pUserData, KillFuncIT pKill);@\\ \mbox{}\verb@ int RemoveCallback(pICallBack pInterface, long iID);@\\ \mbox{}\verb@ int RemoveCallback2(pICallBack pInterface, void *pUserData);@\\ +\mbox{}\verb@@\\ +\mbox{}\verb@ int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData,@\\ +\mbox{}\verb@ int argc, char *argv[]); @\\ +\mbox{}\verb@@\\ +\mbox{}\verb@ pICallBack GetCallbackInterface(void *pData); @\\ \mbox{}\verb@@$\diamond$ \end{list} \vspace{-1ex} @@ -363,8 +368,16 @@ RegisterCallBack. search key for deletion is the pointer to user data. All callbacks related to this user data in the interface specified will be removed. +{\bf CallbackScript} allows to connect callbacks to scripts. Please +note, that those scripts will have a dummy connection to clients only +and will not be able to write to clients. All output occurring in +these scripts will be directed to stdout though, in order to support +debugging. + + All these functions are implemented in the file callback.c. + \subsubsection{The Environment Interface} This interface is used by the environment monitor in order to monitor the status of a environment controller. The interface looks like this: diff --git a/interface.w b/interface.w index 9c515433..02dae748 100644 --- a/interface.w +++ b/interface.w @@ -262,6 +262,11 @@ interface: void *pUserData, KillFuncIT pKill); int RemoveCallback(pICallBack pInterface, long iID); int RemoveCallback2(pICallBack pInterface, void *pUserData); + + int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]); + + pICallBack GetCallbackInterface(void *pData); @} The callback interface has two parts: A part the event generating object has @@ -302,8 +307,16 @@ RegisterCallBack. search key for deletion is the pointer to user data. All callbacks related to this user data in the interface specified will be removed. +{\bf CallbackScript} allows to connect callbacks to scripts. Please +note, that those scripts will have a dummy connection to clients only +and will not be able to write to clients. All output occurring in +these scripts will be directed to stdout though, in order to support +debugging. + + All these functions are implemented in the file callback.c. + \subsubsection{The Environment Interface} This interface is used by the environment monitor in order to monitor the status of a environment controller. The interface looks like this: diff --git a/make_gen b/make_gen index 267da234..2a22935b 100644 --- a/make_gen +++ b/make_gen @@ -29,7 +29,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \ polterwrite.o fourlib.o motreg.o motreglist.o anticollider.o \ s_rnge.o sig_die.o gpibcontroller.o $(NIOBJ) ecb.o ecbdriv.o \ ecbcounter.o hmdata.o tdchm.o nxscript.o A1931.o frame.o \ - tclintimpl.o + tclintimpl.o sicsdata.o MOTOROBJ = motor.o el734driv.o simdriv.o el734dc.o pipiezo.o pimotor.o COUNTEROBJ = countdriv.o simcter.o counter.o diff --git a/motor.c b/motor.c index 379a1a3e..778b55fb 100644 --- a/motor.c +++ b/motor.c @@ -4,8 +4,6 @@ This file implements the SICS motor handling. This is the logical level, the nitty gritty hardware interface is in the driver. - - Mark Koennecke, November 1996 revised: Mark Koennecke, June 1997 callback added: Mark Koennecke, August 1997 @@ -366,8 +364,8 @@ free(pM); return NULL; } - ObParInit(pM->ParArray,HLOW,"hardlowerlim",pDriv->fLower,usInternal); - ObParInit(pM->ParArray,HUPP,"hardupperlim",pDriv->fUpper,usInternal); + ObParInit(pM->ParArray,HLOW,"hardlowerlim",pDriv->fLower,usMugger); + ObParInit(pM->ParArray,HUPP,"hardupperlim",pDriv->fUpper,usMugger); ObParInit(pM->ParArray,SLOW,"softlowerlim",pDriv->fLower,usUser); ObParInit(pM->ParArray,SUPP,"softupperlim",pDriv->fUpper,usUser); ObParInit(pM->ParArray,SZERO,"softzero",ZEROINACTIVE,usUser); diff --git a/motreglist.c b/motreglist.c index 468c200f..2316a3d1 100644 --- a/motreglist.c +++ b/motreglist.c @@ -70,6 +70,27 @@ int CheckAllMotors(int iList, SConnection *pCon){ return count; } /*----------------------------------------------------------------------*/ +void StopAllMotors(int iList){ + int iRet, count = 0; + pMotReg pMot = NULL; + pIDrivable pDriv; + + iRet = LLDnodePtr2First(iList); + while(iRet != 0){ + LLDnodeDataTo(iList,&pMot); + if(pMot != NULL){ + if(pMot->iActive){ + pDriv = (pIDrivable)GetDrivableInterface(pMot->motorData); + if(pDriv){ + pDriv->Halt(pMot->motorData); + } + pMot->iActive = 0; + } + } + iRet = LLDnodePtr2Next(iList); + } +} +/*----------------------------------------------------------------------*/ void KillMotList(int iList){ int iRet; pMotReg pMot = NULL; diff --git a/napi5.c b/napi5.c index 417a6652..46c0b065 100644 --- a/napi5.c +++ b/napi5.c @@ -26,7 +26,6 @@ #include #include #include -#include "fortify.h" typedef struct __NexusFile5 { struct iStack5 { @@ -116,7 +115,8 @@ long gmt_offset; unsigned int vers_major, vers_minor, vers_release, am1 ; hid_t fapl; - int mdc_nelmts, rdcc_nelmts; + int mdc_nelmts; + unsigned long rdcc_nelmts; size_t rdcc_nbytes; double rdcc_w0; @@ -253,14 +253,20 @@ attr1= H5Acreate(pNew->iVID, "file_name", aid1, aid2, H5P_DEFAULT); if (attr1 < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_name attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_name attribute "); return NX_ERROR; } if (H5Awrite(attr1, aid1, (char*)filename) < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_name attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_name attribute "); return NX_ERROR; } + iRet = H5Tclose(aid1); + iRet = H5Sclose(aid2); + iRet = H5Aclose(attr1); + /* ------- library version ------*/ H5get_libversion(&vers_major, &vers_minor, &vers_release); sprintf (version_nr, "%d.%d.%d", vers_major,vers_minor,vers_release); aid2=H5Screate(H5S_SCALAR); @@ -269,24 +275,34 @@ attr1= H5Acreate(pNew->iVID, "HDF5_Version", aid1, aid2, H5P_DEFAULT); if (attr1 < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_name attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_name attribute "); return NX_ERROR; } if (H5Awrite(attr1, aid1, (char*)version_nr) < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_name attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_name attribute "); return NX_ERROR; } + iRet = H5Tclose(aid1); + iRet = H5Sclose(aid2); + iRet = H5Aclose(attr1); + /*----------- file time */ + aid2=H5Screate(H5S_SCALAR); + aid1 = H5Tcopy(H5T_C_S1); H5Tset_size(aid1, strlen(time_buffer)); attr1=H5Acreate(pNew->iVID, "file_time", aid1, aid2, H5P_DEFAULT); if (attr1 < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_time attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_time attribute "); return NX_ERROR; } if (H5Awrite(attr1, aid1, time_buffer) < 0) { - NXIReportError (NXpData, "ERROR: HDF failed to store file_time attribute "); + NXIReportError (NXpData, + "ERROR: HDF failed to store file_time attribute "); return NX_ERROR; } /* Close attribute dataspace */ @@ -330,7 +346,6 @@ free(pFile->iCurrentLD); } free (pFile); - H5garbage_collect(); *fid = NULL; return NX_OK; } @@ -662,22 +677,28 @@ return NX_ERROR; } H5Pset_deflate(cparms,6); - iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, cparms); + iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, + dataspace, cparms); } else if (compress_type == NX_COMP_NONE) { if (dimensions[0] == NX_UNLIMITED) { cparms = H5Pcreate(H5P_DATASET_CREATE); iNew = H5Pset_chunk(cparms,rank,chunkdims); if (iNew < 0) { - NXIReportError (NXpData, "ERROR: Size of chunks could not be set!"); + NXIReportError (NXpData, + "ERROR: Size of chunks could not be set!"); return NX_ERROR; } - iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, cparms); + iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, + dataspace, cparms); } else { - iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, H5P_DEFAULT); + iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, + dataspace, H5P_DEFAULT); } } else { - NXIReportError (NXpData, "HDF5 doesn't support selected compression method! Dataset was saved without compression"); - iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, H5P_DEFAULT); + NXIReportError (NXpData, + "HDF5 doesn't support selected compression method! Dataset was saved without compression"); + iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, + dataspace, H5P_DEFAULT); } if (iRet < 0) { NXIReportError (NXpData, "ERROR: Creating chunked dataset failed!"); @@ -1165,6 +1186,7 @@ strcpy(nxclass,data); H5Tclose(atype); H5Gclose(grp); + H5Aclose(attr1); } else if (op_data.type==H5G_DATASET) { grp=H5Dopen(pFile->iCurrentG,name); diff --git a/nxamor.c b/nxamor.c index e2c36584..93cefbae 100644 --- a/nxamor.c +++ b/nxamor.c @@ -354,7 +354,7 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, NXhandle hfil, NXdict hdict, SConnection *pCon) { - int iLength, nChunk, chunkSize, iChunk[3], i, iStart[3], nTime; + int iLength, nChunk, chunkSize, iChunk[3], i, iStart[3], nTime, iRet; HistInt *lData = NULL; char pBueffel[132]; const float *fTime; @@ -371,11 +371,19 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { SCWrite(pCon, "ERROR: out of memory, failed to write histogram",eError); + SCSetInterrupt(pCon,eAbortBatch); return 0; } memset(lData,0,iLength*sizeof(HistInt)); - GetHistogramDirect(pHM,pCon, + iRet = GetHistogramDirect(pHM,pCon, 0,0,iLength,lData,iLength*sizeof(HistInt)); + if(!iRet) + { + SCWrite(pCon,"ERROR: failed to read Hm data",eError); + SCSetInterrupt(pCon,eAbortBatch); + free(lData); + return 0; + } NXDputalias(hfil,hdict,name,lData); NXDputalias(hfil,hdict,"detchunk",iDim); NXDaliaslink(hfil,hdict,"dana",name); @@ -417,15 +425,23 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { SCWrite(pCon,"ERROR: out of memory while writing TOF data", eError); + SCSetInterrupt(pCon,eAbortBatch); return 0; } NXDopenalias(hfil,hdict,name); for(i = 0; i < iDim[1]/iChunk[1]; i++) { memset(lData,0,chunkSize*sizeof(HistInt)); - GetHistogramDirect(pHM,pCon, + iRet = GetHistogramDirect(pHM,pCon, 0,i*chunkSize,(i+1)*chunkSize,lData, chunkSize*sizeof(HistInt)); + if(!iRet) + { + SCWrite(pCon,"ERROR: failed to read HM data",eError); + SCSetInterrupt(pCon,eAbortBatch); + free(lData); + return 0; + } /* yield a little in order to allow other clients to receive a response. Also allow for interrupting. @@ -475,6 +491,7 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, } if(lData) free(lData); + return 1; } /*-----------------------------------------------------------------------*/ int WriteAmorTOF(char *file, SConnection *pCon, pHistMem pHM) @@ -604,28 +621,50 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { SCWrite(pCon,"ERROR: out of memory while writing time binning", eError); + SCSetInterrupt(pCon,eAbortBatch); + NXclose(&hfil); + NXDclose(hdict,NULL); + return 0; } /* finally get histogram */ if(iDim[2] == 2) /* 2D data, no time binning on this detector */ { - iLength = detxsize*detysize; + iLength = detxsize*detysize; lData = (HistInt *)malloc(iLength*sizeof(HistInt)); if(!lData) { SCWrite(pCon, "ERROR: out of memory, failed to write histogram",eError); + NXclose(&hfil); + NXDclose(hdict,NULL); + SCSetInterrupt(pCon,eAbortBatch); return 0; } memset(lData,0,iLength*sizeof(HistInt)); - GetHistogram(pHM,pCon, 0,0,iLength,lData,iLength*sizeof(HistInt)); + iRet = GetHistogram(pHM,pCon, 0,0,iLength, + lData,iLength*sizeof(HistInt)); + if(!iRet) + { + SCWrite(pCon,"ERROR: failed to read HM", eError); + SCSetInterrupt(pCon,eAbortBatch); + NXclose(&hfil); + NXDclose(hdict,NULL); + return 0; + } NXDputalias(hfil,hdict,"spinup2d",lData); NXDaliaslink(hfil,hdict,"dana","spinup2d"); } else { if(psdSave){ - WriteTOFDetector("spinup",pHM, iDim,hfil,hdict,pCon); + iRet = WriteTOFDetector("spinup",pHM, iDim,hfil,hdict,pCon); + if(!iRet) + { + NXclose(&hfil); + NXDclose(hdict,NULL); + return 0; + } } else { SCWrite(pCon,"PSD writing supressed!",eWarning); } @@ -639,13 +678,27 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { SCWrite(pCon,"ERROR: out of memory while writing single detectors", eError); + SCSetInterrupt(pCon,eAbortBatch); + NXclose(&hfil); + NXDclose(hdict,NULL); + return 0; } else { memset(lData,0,MAXSINGLE*iDim[2]*sizeof(HistInt)); - GetHistogramDirect(pHM,pCon,0,iLength, + iRet = GetHistogramDirect(pHM,pCon,0,iLength, iLength + MAXSINGLE*iDim[2], lData, MAXSINGLE*iDim[2]*sizeof(HistInt)); + if(!iRet) + { + SCWrite(pCon,"ERROR: failed to read single detector HM data", + eError); + SCSetInterrupt(pCon,eAbortBatch); + free(lData); + NXclose(&hfil); + NXDclose(hdict,NULL); + return 0; + } NXDputalias(hfil,hdict,"singleup",lData); NXDaliaslink(hfil,hdict,"singledana","singleup"); NXDaliaslink(hfil,hdict,"singledana","singletime"); diff --git a/obdes.h b/obdes.h index 76443e59..6fe95697 100644 --- a/obdes.h +++ b/obdes.h @@ -1,5 +1,5 @@ -#line 342 "interface.w" +#line 355 "interface.w" #line 29 "interface.w" @@ -52,5 +52,5 @@ typedef struct { #endif -#line 343 "interface.w" +#line 356 "interface.w" diff --git a/ofac.c b/ofac.c index f220d952..39c21e83 100644 --- a/ofac.c +++ b/ofac.c @@ -113,6 +113,7 @@ #include "nxscript.h" #include "frame.h" #include "tclintimpl.h" +#include "sicsdata.h" /*----------------------- Server options creation -------------------------*/ static int IFServerOption(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) @@ -233,6 +234,8 @@ AddCommand(pInter,"udpquieck",QuieckAction,KillQuieck,NULL); AddCommand(pInter,"alias",MakeAlias,NULL,NULL); AddCommand(pInter,"sicscron",MakeCron,NULL,NULL); + AddCommand(pInter,"sicsdatafactory",SICSDataFactory,NULL,NULL); + AddCommand(pInter,"scriptcallback",CallbackScript,NULL,NULL); /* commands to do with the executor. Only StopExe carries the DeleteFunction in order to avoid double deletion. All the diff --git a/scan.c b/scan.c index 1b08d6ac..f0267ae4 100644 --- a/scan.c +++ b/scan.c @@ -2112,7 +2112,7 @@ int StoreScanCounts(pScanData self, char *data) GetScanCounts(self,lData,self->iNP); /* copy them */ memset(iData,0,self->iNP+1); - iData[0] = self->iNP; + iData[0] = htonl(self->iNP); for(i = 0; i < self->iNP; i++) { iData[i+1] = htonl(lData[i]); @@ -2121,6 +2121,22 @@ int StoreScanCounts(pScanData self, char *data) (self->iNP + 1)*sizeof(int)); return 1; } +/*--------- noscanvar */ + else if(strcmp(argv[1],"noscanvar") == 0) + { + sprintf(pBueffel,"%s.noscanvar = %d",argv[0], + self->iScanVar); + SCWrite(pCon,pBueffel,eValue); + return 1; + } +/*-------- NP */ + else if(strcmp(argv[1],"np") == 0) + { + sprintf(pBueffel,"%s.nP = %d",argv[0], + self->iNP); + SCWrite(pCon,pBueffel,eValue); + return 1; + } /*--------- getvardata */ else if(strcmp(argv[1],"getvardata") == 0) { diff --git a/sicsdata.c b/sicsdata.c new file mode 100644 index 00000000..b533b51f --- /dev/null +++ b/sicsdata.c @@ -0,0 +1,598 @@ +/*--------------------------------------------------------------------- + S I C S D A T A + + An attempt to a generic interface to SICS data for all sorts of SICS + clients. + + copyright: see file COPYRIGHT + + Mark Koennecke, June 2003 +----------------------------------------------------------------------*/ +#include +#include +#include +#include "fortify.h" +#include "sics.h" +#include "splitter.h" +#include "scan.h" +#include "HistMem.h" +#include "sicsdata.h" + +#define INTTYPE 0 +#define FLOATTYPE 1 +/*--------------------------------------------------------------------*/ +static void KillSICSData(void *pData){ + pSICSData self = NULL; + + self = (pSICSData)pData; + if(!self){ + return; + } + if(self->data != NULL){ + free(self->data); + } + if(self->dataType != NULL){ + free(self->dataType); + } + if(self->pDes != NULL){ + DeleteDescriptor(self->pDes); + } + free(self); +} +/*---------------------------------------------------------------------*/ +pSICSData createSICSData(void){ + pSICSData pNew = NULL; + + pNew = (pSICSData)malloc(sizeof(SICSData)); + if(!pNew){ + return NULL; + } + memset(pNew,0,sizeof(SICSData)); + pNew->pDes = CreateDescriptor("SICSData"); + pNew->data = (int *)malloc(1024*sizeof(int)); + pNew->dataType = (char *)malloc(1024*sizeof(char)); + if(pNew->pDes == NULL || pNew->data == NULL || + pNew->dataType == NULL){ + KillSICSData(pNew); + return NULL; + } + memset(pNew->data,0,1024*sizeof(int)); + memset(pNew->dataType,0,1024*sizeof(char)); + pNew->currentDataSize = 1024; + pNew->dataUsed = 0; + return pNew; +} +/*-------------------------------------------------------------------*/ +int *getSICSDataPointer(pSICSData self, int start, int end){ + int newSize; + int *newData = NULL; + char *newType = NULL; + + assert(self); + if(end >= self->currentDataSize) { + /* we have to resize */ + if(self->currentDataSize*2 > end){ + newSize = self->currentDataSize * 2.; + }else { + newSize = end + self->dataUsed; + } + newData = (int *)malloc(newSize*sizeof(int)); + newType = (char *)malloc(newSize*sizeof(char)); + if(newData == NULL || newType == NULL){ + return NULL; + } + memset(newData,0,newSize*sizeof(int)); + memset(newType,0,newSize*sizeof(char)); + memcpy(newData,self->data,self->dataUsed*sizeof(int)); + memcpy(newType,self->dataType,self->dataUsed*sizeof(char)); + free(self->data); + free(self->dataType); + self->data = newData; + self->dataType = newType; + self->currentDataSize = newSize; + } + if(end > self->dataUsed){ + self->dataUsed = end; + } + return &self->data[start]; +} +/*------------------------------------------------------------------------ + assign a type to a couple of data values +--------------------------------------------------------------------------*/ +static void assignType(pSICSData self, int start, int end, int type){ + int i; + + assert(self); + assert(end <= self->currentDataSize); + assert(type == INTTYPE || type == FLOATTYPE); + + for(i = start; i < end; i++){ + self->dataType[i] = type; + } +} +/*------------------------------------------------------------------------ +netEncode transforms the data in the array into network format. +- int become ints in network byte order +- floats become fixed point and thus ints in network byte order as well +-------------------------------------------------------------------------*/ +static void netEncode(pSICSData self){ + int i; + float fVal; + + assert(self); + for(i = 0; i < self->dataUsed; i++){ + if(self->dataType[i] == INTTYPE){ + self->data[i] = htonl(self->data[i]); + } + if(self->dataType[i] == FLOATTYPE){ + memcpy(&fVal,self->data + i,sizeof(float)); + fVal /= 65536.; + self->data[i] = htonl((int)fVal); + } + } +} +/*---------------------------------------------------------------------*/ +static void clearSICSData(pSICSData self){ + assert(self); + + self->dataUsed = 0; + memset(self->data,0,self->currentDataSize*sizeof(int)); + memset(self->dataType,0,self->currentDataSize*sizeof(char)); +} +/*--------------------------------------------------------------------*/ +static int dumpSICSData(pSICSData self, char *filename, SConnection *pCon){ + FILE *fd = NULL; + char pBueffel[132]; + int i; + float fVal; + + fd = fopen(filename,"w"); + if(fd == NULL){ + snprintf(pBueffel,131,"ERROR: cannot open %s", filename); + SCWrite(pCon,pBueffel,eError); + return 0; + } + for(i = 0; i < self->dataUsed; i++){ + if(self->dataType[i] == INTTYPE){ + fprintf(fd,"%10d %25d\n",i,self->data[i]); + } + if(self->dataType[i] == FLOATTYPE){ + memcpy(&fVal,self->data + i,sizeof(float)); + fprintf(fd,"%10d %25.5f\n",i,fVal); + } + } + fclose(fd); + SCSendOK(pCon); + return 1; +} +/*-------------------------------------------------------------------*/ +static int putInt(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, iVal, pos, *iData = NULL; + + assert(self); + + if(argc < 2) { + SCWrite(pCon,"ERROR: not enough arguments to SICSData putint",eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon,"ERROR: failed to convert putint position to integer", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[1],&iVal); + if(status != TCL_OK){ + SCWrite(pCon,"ERROR: failed to convert putint value to integer", + eError); + return 0; + } + iData = getSICSDataPointer(self,pos,pos+1); + if(!iData){ + SCWrite(pCon,"ERROR: out of memory in putint",eError); + return 0; + } + *iData = iVal; + SCSendOK(pCon); + self->dataType[pos] = INTTYPE; + return 1; +} +/*-------------------------------------------------------------------*/ +static int putFloat(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, pos, *iData = NULL; + float fVal; + double dVal; + + assert(self); + + if(argc < 2) { + SCWrite(pCon,"ERROR: not enough arguments to SICSData putfloat",eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon,"ERROR: failed to convert putfloat position to integer", + eError); + return 0; + } + status = Tcl_GetDouble(InterpGetTcl(pSics),argv[1],&dVal); + if(status != TCL_OK){ + SCWrite(pCon,"ERROR: failed to convert putint value to float", + eError); + return 0; + } + iData = getSICSDataPointer(self,pos,pos+1); + if(!iData){ + SCWrite(pCon,"ERROR: out of memory in putfloat",eError); + return 0; + } + fVal = (float)dVal; + memcpy(iData,&fVal,sizeof(float)); + self->dataType[pos] = FLOATTYPE; + SCSendOK(pCon); + return 1; +} +/*-------------------------------------------------------------------*/ +static int copyScanCounts(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, pos, np ,i; + pScanData pScan = NULL; + int *iData = NULL; + long *lData = NULL; + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to SICSData copyscancounts", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyscancounts position to integer", + eError); + return 0; + } + pScan = FindCommandData(pSics,argv[1],"ScanObject"); + if(!pScan){ + SCWrite(pCon,"ERROR: scan object not found in copyscancounts", + eError); + return 0; + } + np = GetScanNP(pScan); + iData = getSICSDataPointer(self,pos,pos+np); + lData = (long *)malloc(np*sizeof(long)); + if(!iData || !lData){ + SCWrite(pCon,"ERROR: out of memory in copyscancounts",eError); + return 0; + } + memset(lData,0,np*sizeof(long)); + GetScanCounts(pScan,lData,np); + for(i = 0; i < np; i++){ + self->data[pos + i] = (int)lData[i]; + self->dataType[pos + i] = INTTYPE; + } + free(lData); + SCSendOK(pCon); + return 1; +} +/*-------------------------------------------------------------------*/ +static int copyScanMonitor(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, pos, np ,i, monitor; + pScanData pScan = NULL; + int *iData = NULL; + long *lData = NULL; + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to SICSData copyscanmon", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyscancounts position to integer", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&monitor); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyscancounts monitor to integer", + eError); + return 0; + } + pScan = FindCommandData(pSics,argv[1],"ScanObject"); + if(!pScan){ + SCWrite(pCon,"ERROR: scan object not found in copyscanmonitor", + eError); + return 0; + } + np = GetScanNP(pScan); + iData = getSICSDataPointer(self,pos,pos+np); + lData = (long *)malloc(np*sizeof(long)); + if(!iData || !lData){ + SCWrite(pCon,"ERROR: out of memory in copyscanmonitor",eError); + return 0; + } + memset(lData,0,np*sizeof(long)); + GetScanMonitor(pScan,monitor,lData,np); + for(i = 0; i < np; i++){ + self->data[pos + i] = (int)lData[i]; + self->dataType[pos + i] = INTTYPE; + } + free(lData); + SCSendOK(pCon); + return 1; +} +/*-------------------------------------------------------------------*/ +static int copyScanVar(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, pos, np ,i, var; + pScanData pScan = NULL; + int *iData = NULL; + float *fData = NULL; + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to SICSData copyscanvar", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyscanvar position to integer", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&var); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyscanvar varID to integer", + eError); + return 0; + } + pScan = FindCommandData(pSics,argv[1],"ScanObject"); + if(!pScan){ + SCWrite(pCon,"ERROR: scan object not found in copyscanvar", + eError); + return 0; + } + np = GetScanNP(pScan); + iData = getSICSDataPointer(self,pos,pos+np); + fData = (float *)malloc(np*sizeof(float)); + if(!iData || !fData){ + SCWrite(pCon,"ERROR: out of memory in copyscanvar",eError); + return 0; + } + memset(fData,0,np*sizeof(float)); + GetSoftScanVar(pScan,var,fData,np); + for(i = 0; i < np; i++){ + memcpy(self->data + pos +i,fData + i,sizeof(float)); + self->dataType[pos + i] = FLOATTYPE; + } + free(fData); + SCSendOK(pCon); + return 1; +} +/*--------------------------------------------------------------------*/ +static int copyTimeBin(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, noTimeBin, pos, i; + pHistMem pHist = NULL; + const float *fTimeBin = NULL; + int *iData = NULL; + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to SICSData copytimebin", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copytimebin position to integer", + eError); + return 0; + } + pHist = (pHistMem)FindCommandData(pSics,argv[1],"HistMem"); + if(!pHist){ + SCWrite(pCon,"ERROR: histogram memory not found in copytimebin", + eError); + return 0; + } + fTimeBin = GetHistTimeBin(pHist,&noTimeBin); + iData = getSICSDataPointer(self,pos,pos+noTimeBin); + if(!fTimeBin || !iData){ + SCWrite(pCon,"ERROR: out of memory in SICSData copytimebin",eError); + return 0; + } + for(i = 0; i < noTimeBin; i++){ + memcpy(iData + pos + i, fTimeBin + i, sizeof(float)); + self->dataType[pos+i] = FLOATTYPE; + } + SCSendOK(pCon); + return 1; +} +/*--------------------------------------------------------------------*/ +static int copyHM(pSICSData self, int argc, char *argv[], + SConnection *pCon, SicsInterp *pSics){ + int status, pos, i, subset = 0, start, end; + pHistMem pHist = NULL; + const float *fTimeBin = NULL; + int *iData = NULL; + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to SICSData copyhm", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[0],&pos); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyhm position to integer", + eError); + return 0; + } + pHist = (pHistMem)FindCommandData(pSics,argv[1],"HistMem"); + if(!pHist){ + SCWrite(pCon,"ERROR: histogram memory not found in copytimebin", + eError); + return 0; + } + start = 0; + end = GetHistLength(pHist); + + if(argc > 3) { + subset = 1; + status = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&start); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyhm start to integer", + eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics),argv[3],&end); + if(status != TCL_OK){ + SCWrite(pCon, + "ERROR: failed to convert copyhm end to integer", + eError); + return 0; + } + } + + iData = getSICSDataPointer(self,pos,pos+(end-start)); + if(!iData){ + SCWrite(pCon,"ERROR: out of memory in SICSData copyhm",eError); + return 0; + } + GetHistogramDirect(pHist,pCon,0,start,end,iData,(end-start)*sizeof(int)); + assignType(self,pos,pos+(end-start),INTTYPE); + SCSendOK(pCon); + return 1; +} +/*---------------------------------------------------------------------- + Look here in order to find out about commands understood + ----------------------------------------------------------------------*/ +int SICSDataAction(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]){ + pSICSData self = NULL; + char pBueffel[132]; + + self = (pSICSData)pData; + assert(self); + + if(argc < 2){ + SCWrite(pCon,"ERROR: not enough arguments to act upon data",eError); + return 0; + } + strtolower(argv[1]); + + /*------ clear*/ + if(strcmp(argv[1],"clear") == 0){ + clearSICSData(self); + SCSendOK(pCon); + return 1; + } else if (strcmp(argv[1],"used") == 0){ + /*--------- used */ + snprintf(pBueffel,131,"%s = %d", argv[0], self->dataUsed); + SCWrite(pCon,pBueffel,eValue); + return 1; + } else if(strcmp(argv[1],"dump") == 0){ + /* --------- dump */ + if(argc < 3){ + SCWrite(pCon,"ERROR: need a file name to dump to",eError); + return 0; + } + return dumpSICSData(self,argv[2],pCon); + } else if(strcmp(argv[1],"putint") == 0){ + /*---------- putint */ + return putInt(self,argc-2,&argv[2],pCon, pSics); + } else if(strcmp(argv[1],"putfloat") == 0){ + /*---------- putfloat */ + return putFloat(self,argc-2,&argv[2],pCon, pSics); + } else if(strcmp(argv[1],"copyscancounts") == 0){ + /*-------- copyscancounts*/ + return copyScanCounts(self,argc-2,&argv[2],pCon,pSics); + } else if(strcmp(argv[1],"copyscanmon") == 0){ + /*-------- copyscanmon*/ + return copyScanMonitor(self,argc-2,&argv[2],pCon,pSics); + } else if(strcmp(argv[1],"copyscanvar") == 0){ + /*--------- copyscanvar */ + return copyScanVar(self,argc-2,&argv[2],pCon,pSics); + } else if(strcmp(argv[1],"copytimebin") == 0){ + /*--------- copytimebin */ + return copyTimeBin(self,argc-2,&argv[2],pCon,pSics); + } else if(strcmp(argv[1],"copyhm") == 0){ + /*--------- copytimebin */ + return copyHM(self,argc-2,&argv[2],pCon,pSics); + } else if(strcmp(argv[1],"writezipped") == 0){ + /*--------- writezipped */ + if(argc < 3){ + SCWrite(pCon,"ERROR: need a name for writezipped",eError); + return 0; + } + netEncode(self); + SCWriteZipped(pCon,argv[2],self->data,self->dataUsed*sizeof(int)); + return 1; + } else if(strcmp(argv[1],"writeuu") == 0){ + /*--------- writeuu */ + if(argc < 3){ + SCWrite(pCon,"ERROR: need a name for writeuu",eError); + return 0; + } + netEncode(self); + SCWriteUUencoded(pCon,argv[2],self->data,self->dataUsed*sizeof(int)); + return 1; + } + + SCWrite(pCon,"ERROR: object command to SICSData not recognized",eError); + return 0; +} +/*----------------------------------------------------------------------*/ +int SICSDataFactory(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]){ + pSICSData self = NULL; + int iRet; + + if(argc < 3){ + SCWrite(pCon,"ERROR: not enough arguments to SICSDataFactory",eError); + return 0; + } + strtolower(argv[1]); + strtolower(argv[2]); + + if(strcmp(argv[1],"new") == 0){ + self = createSICSData(); + if(self == NULL){ + SCWrite(pCon,"ERROR: not enough memory to create SICSData",eError); + return 0; + } + iRet = AddCommand(pSics,argv[2],SICSDataAction,KillSICSData, + self); + if(!iRet){ + SCWrite(pCon,"ERROR: new SICSData not created due to name collision", + eError); + KillSICSData(self); + return 0; + } + SCSendOK(pCon); + return 1; + } else if(strcmp(argv[1],"del") == 0){ + self = (pSICSData)FindCommandData(pSics,argv[2],"SICSData"); + if(self == NULL){ + SCWrite(pCon,"ERROR: SICSData to kill not found!",eError); + return 0; + } + RemoveCommand(pSics,argv[2]); + SCSendOK(pCon); + return 1; + } + SCWrite(pCon,"ERROR: object command to SICSData not recognized",eError); + return 0; +} + + + diff --git a/sicsdata.h b/sicsdata.h new file mode 100644 index 00000000..88e0b7c4 --- /dev/null +++ b/sicsdata.h @@ -0,0 +1,38 @@ + +/*--------------------------------------------------------------------- + S I C S D A T A + + An attempt to a generic interface to SICS data for all sorts of SICS + clients. + + copyright: see file COPYRIGHT + + Mark Koennecke, June 2003 +----------------------------------------------------------------------*/ +#ifndef SICSDATA +#define SICSDATA + + typedef struct { + pObjectDescriptor pDes; + int *data; + char *dataType; + int dataUsed; + int currentDataSize; + }SICSData, *pSICSData; + + +/*------------------------------------------------------------------*/ + + int *getSICSDataPointer(pSICSData self, int start, int end); + + pSICSData createSICSData(void); + + int SICSDataFactory(SConnection *pCon, SicsInterp *pSics, + void *pData, + int argc, char *argv[]); + + int SICSDataAction(SConnection *pCon, SicsInterp *pSics, + void *pData, + int argc, char *argv[]); + +#endif diff --git a/sicsdata.w b/sicsdata.w new file mode 100644 index 00000000..0a4463d6 --- /dev/null +++ b/sicsdata.w @@ -0,0 +1,78 @@ +\subsection{SICS Generic Data} +This is an attempt to create a generic interface between SICS data and +clients. At the bottom of it is a auto resizing array of data. Data +can be entered into this array either manually or copied from data +sources such as histogram memories or scans. Data assembled in this +way, for instance through scripts, can then be forwarded to clients +either in UUencoded form or as a zipped array. + +In a later stage this may be extended to support selected mathematical +operations as well. In another stage this may supersede the uuget and +zipget methods in the scan, histogram memory and specialized status +objects. + +This needs a data structure: +@d sidastruc @{ + typedef struct { + pObjectDescriptor pDes; + int *data; + char *dataType; + int dataUsed; + int currentDataSize; + }SICSData, *pSICSData; + +@} +The fields: +\begin{description} +\item[pDes] The standard object descriptor. +\item[data] The actual data array. This code assumes that sizeof(int) +== sizeof(float). +\item[dataType] An array defining the data type for each element of +data. Supported are: 4 byte int and 4 byte float. +\item[dataUsed] is the highest data element adressed so far. +\item[currentDataSize] is the size of data. +\end{description} + +This object exports the following functions: +@d sidafunc @{ + int *getSICSDataPointer(pSICSData self, int start, int end); + + pSICSData createSICSData(void); + + int SICSDataFactory(SConnection *pCon, SicsInterp *pSics, + void *pData, + int argc, char *argv[]); + + int SICSDataAction(SConnection *pCon, SicsInterp *pSics, + void *pData, + int argc, char *argv[]); +@} +\begin{description} +\item[getSICSDataPointer] returns a pointer to the first element of +start in the data array. It is also ensured that enough space is +available till end. +\item[createSICSData] creates a new SICSData structure. +\item[SICSDataFactory] is an interpreter function for creating and +deleting SICSData things. +\item[SICSDataAction] is the interpreter wrapper function through +which users may interact with the SICSData element. +\end{description} + +@o sicsdata.h @{ +/*--------------------------------------------------------------------- + S I C S D A T A + + An attempt to a generic interface to SICS data for all sorts of SICS + clients. + + copyright: see file COPYRIGHT + + Mark Koennecke, June 2003 +----------------------------------------------------------------------*/ +#ifndef SICSDATA +#define SICSDATA +@ +/*------------------------------------------------------------------*/ +@ +#endif +@} diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 66737a12..b4b0fd9a 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -1,7 +1,6 @@ # naff was here , best wishes # naff was here , best wishes # naff was here , best wishes -run anticollision 77.769997 yfactor 1.420000 yfactor setAccess 1 xfactor 0.715000 @@ -91,8 +90,8 @@ om SoftLowerLim -73.000000 om SoftUpperLim 134.000000 om Fixed -1.000000 om InterruptMode 0.000000 +om precision 0.010000 om AccessCode 2.000000 -run om 103.500000 # Motor stt stt sign 1.000000 stt SoftZero 0.000000 @@ -100,8 +99,8 @@ stt SoftLowerLim 4.000000 stt SoftUpperLim 113.000000 stt Fixed -1.000000 stt InterruptMode 0.000000 +stt precision 0.010000 stt AccessCode 2.000000 -run stt 120.000000 # Motor ch ch sign 1.000000 ch SoftZero 0.000000 @@ -109,8 +108,8 @@ ch SoftLowerLim 0.000000 ch SoftUpperLim 190.000000 ch Fixed -1.000000 ch InterruptMode 0.000000 +ch precision 0.010000 ch AccessCode 1.000000 -run ch 180.000000 # Motor ph ph sign 1.000000 ph SoftZero 0.000000 @@ -118,8 +117,8 @@ ph SoftLowerLim -360.000000 ph SoftUpperLim 360.000000 ph Fixed -1.000000 ph InterruptMode 0.000000 +ph precision 0.010000 ph AccessCode 2.000000 -run ph 360.000000 # Motor dg3 dg3 sign 1.000000 dg3 SoftZero 0.000000 @@ -127,8 +126,8 @@ dg3 SoftLowerLim -10.000000 dg3 SoftUpperLim 40.000000 dg3 Fixed -1.000000 dg3 InterruptMode 0.000000 +dg3 precision 0.010000 dg3 AccessCode 2.000000 -run dg3 25.000000 # Motor dg2 dg2 sign 1.000000 dg2 SoftZero 0.000000 @@ -136,8 +135,8 @@ dg2 SoftLowerLim -10.000000 dg2 SoftUpperLim 40.000000 dg2 Fixed -1.000000 dg2 InterruptMode 0.000000 +dg2 precision 0.010000 dg2 AccessCode 2.000000 -run dg2 25.000000 # Motor dg1 dg1 sign 1.000000 dg1 SoftZero 0.000000 @@ -145,8 +144,8 @@ dg1 SoftLowerLim -10.000000 dg1 SoftUpperLim 40.000000 dg1 Fixed -1.000000 dg1 InterruptMode 0.000000 +dg1 precision 0.010000 dg1 AccessCode 2.000000 -run dg1 25.000000 # Motor muca muca sign 1.000000 muca SoftZero 0.000000 @@ -154,8 +153,8 @@ muca SoftLowerLim 30.000000 muca SoftUpperLim 36.000000 muca Fixed -1.000000 muca InterruptMode 0.000000 +muca precision 0.010000 muca AccessCode 2.000000 -run muca 3.000000 # Motor phi phi sign 1.000000 phi SoftZero 0.000000 @@ -163,8 +162,8 @@ phi SoftLowerLim -360.000000 phi SoftUpperLim 360.000000 phi Fixed -1.000000 phi InterruptMode 0.000000 +phi precision 0.010000 phi AccessCode 2.000000 -run phi 360.000000 # Motor chi chi sign 1.000000 chi SoftZero 0.000000 @@ -172,8 +171,8 @@ chi SoftLowerLim 0.000000 chi SoftUpperLim 190.000000 chi Fixed -1.000000 chi InterruptMode 0.000000 +chi precision 0.010000 chi AccessCode 1.000000 -run chi 180.000000 # Motor omega omega sign 1.000000 omega SoftZero 0.000000 @@ -181,8 +180,8 @@ omega SoftLowerLim -73.000000 omega SoftUpperLim 134.000000 omega Fixed -1.000000 omega InterruptMode 0.000000 +omega precision 0.010000 omega AccessCode 2.000000 -run omega 103.500000 # Motor twotheta twotheta sign 1.000000 twotheta SoftZero 0.000000 @@ -190,9 +189,9 @@ twotheta SoftLowerLim 4.000000 twotheta SoftUpperLim 113.000000 twotheta Fixed -1.000000 twotheta InterruptMode 0.000000 +twotheta precision 0.010000 twotheta AccessCode 2.000000 -run twotheta 120.000000 -lastscancommand cscan som .85 .05 16 1 +lastscancommand sscan a3 100 110 10 1 lastscancommand setAccess 2 sample_mur 0.000000 sample_mur setAccess 2 @@ -204,8 +203,6 @@ phone UNKNOWN phone setAccess 2 adress UNKNOWN adress setAccess 2 -run o2t 130.000000 -run lambda 5.321338 # Counter counter counter SetPreset 1.000000 counter SetMode Monitor @@ -216,8 +213,8 @@ som SoftLowerLim -340.000000 som SoftUpperLim 380.000000 som Fixed -1.000000 som InterruptMode 0.000000 +som precision 0.010000 som AccessCode 2.000000 -run som 120.000000 # Motor sax sax sign 1.000000 sax SoftZero 0.000000 @@ -225,10 +222,8 @@ sax SoftLowerLim -30.000000 sax SoftUpperLim 30.000000 sax Fixed -1.000000 sax InterruptMode 0.000000 +sax precision 0.010000 sax AccessCode 2.000000 -run sax 30.000000 -run lumbda 0.000000 -run nvs 0.000000 # Motor tilt tilt sign 1.000000 tilt SoftZero 0.000000 @@ -236,12 +231,30 @@ tilt SoftLowerLim -15.000000 tilt SoftUpperLim 15.000000 tilt Fixed -1.000000 tilt InterruptMode 0.000000 +tilt precision 0.010000 tilt AccessCode 0.000000 -run tilt 15.000000 #----- MultiMotor st st recovernampos henry d1r 5. d1l -5. d1t 0. #----- MultiMotor sampletable sampletable recovernampos henry d1r 5. d1l -5. d1t 0. +# Motor cex2 +cex2 sign 1.000000 +cex2 SoftZero 0.000000 +cex2 SoftLowerLim -360.000000 +cex2 SoftUpperLim 360.000000 +cex2 Fixed -1.000000 +cex2 InterruptMode 0.000000 +cex2 precision 0.010000 +cex2 AccessCode 2.000000 +# Motor cex1 +cex1 sign 1.000000 +cex1 SoftZero 0.000000 +cex1 SoftLowerLim -360.000000 +cex1 SoftUpperLim 360.000000 +cex1 Fixed -1.000000 +cex1 InterruptMode 0.000000 +cex1 precision 0.010000 +cex1 AccessCode 2.000000 # Motor detectorrotation detectorrotation sign 1.000000 detectorrotation SoftZero 0.000000 @@ -249,8 +262,8 @@ detectorrotation SoftLowerLim -20.000000 detectorrotation SoftUpperLim 20.000000 detectorrotation Fixed -1.000000 detectorrotation InterruptMode 0.000000 +detectorrotation precision 0.010000 detectorrotation AccessCode 2.000000 -run detectorrotation 20.000000 # Motor detectory detectory sign 1.000000 detectory SoftZero 0.000000 @@ -258,8 +271,8 @@ detectory SoftLowerLim -20.000000 detectory SoftUpperLim 20.000000 detectory Fixed -1.000000 detectory InterruptMode 0.000000 +detectory precision 0.010000 detectory AccessCode 2.000000 -run detectory 20.000000 # Motor detectorx detectorx sign 1.000000 detectorx SoftZero 0.000000 @@ -267,8 +280,8 @@ detectorx SoftLowerLim -20.000000 detectorx SoftUpperLim 20.000000 detectorx Fixed -1.000000 detectorx InterruptMode 0.000000 +detectorx precision 0.010000 detectorx AccessCode 2.000000 -run detectorx 20.000000 # Motor beamstopy beamstopy sign 1.000000 beamstopy SoftZero 0.000000 @@ -276,8 +289,8 @@ beamstopy SoftLowerLim -20.000000 beamstopy SoftUpperLim 20.000000 beamstopy Fixed -1.000000 beamstopy InterruptMode 0.000000 +beamstopy precision 0.010000 beamstopy AccessCode 2.000000 -run beamstopy 20.000000 # Motor beamstopx beamstopx sign 1.000000 beamstopx SoftZero 0.000000 @@ -285,8 +298,8 @@ beamstopx SoftLowerLim -20.000000 beamstopx SoftUpperLim 20.000000 beamstopx Fixed -1.000000 beamstopx InterruptMode 0.000000 +beamstopx precision 0.010000 beamstopx AccessCode 2.000000 -run beamstopx 20.000000 # Motor d2t d2t sign 1.000000 d2t SoftZero 0.000000 @@ -294,8 +307,8 @@ d2t SoftLowerLim -20.000000 d2t SoftUpperLim 20.000000 d2t Fixed -1.000000 d2t InterruptMode 0.000000 +d2t precision 0.010000 d2t AccessCode 2.000000 -run d2t 20.000000 # Motor d2l d2l sign 1.000000 d2l SoftZero 0.000000 @@ -303,8 +316,8 @@ d2l SoftLowerLim -20.000000 d2l SoftUpperLim 20.000000 d2l Fixed -1.000000 d2l InterruptMode 0.000000 +d2l precision 0.010000 d2l AccessCode 2.000000 -run d2l 20.000000 # Motor d2r d2r sign 1.000000 d2r SoftZero 0.000000 @@ -312,8 +325,8 @@ d2r SoftLowerLim -20.000000 d2r SoftUpperLim 20.000000 d2r Fixed -1.000000 d2r InterruptMode 0.000000 +d2r precision 0.010000 d2r AccessCode 2.000000 -run d2r 20.000000 # Motor d1t d1t sign 1.000000 d1t SoftZero 0.000000 @@ -321,8 +334,8 @@ d1t SoftLowerLim -20.000000 d1t SoftUpperLim 20.000000 d1t Fixed -1.000000 d1t InterruptMode 0.000000 +d1t precision 0.010000 d1t AccessCode 2.000000 -run d1t 20.000000 # Motor d1l d1l sign 1.000000 d1l SoftZero 0.000000 @@ -330,8 +343,8 @@ d1l SoftLowerLim -20.000000 d1l SoftUpperLim 20.000000 d1l Fixed -1.000000 d1l InterruptMode 0.000000 +d1l precision 0.010000 d1l AccessCode 2.000000 -run d1l 20.000000 # Motor d1r d1r sign 1.000000 d1r SoftZero 0.000000 @@ -339,8 +352,8 @@ d1r SoftLowerLim -20.000000 d1r SoftUpperLim 20.000000 d1r Fixed -1.000000 d1r InterruptMode 0.000000 +d1r precision 0.010000 d1r AccessCode 2.000000 -run d1r 20.000000 # Motor monochi monochi sign 1.000000 monochi SoftZero 0.000000 @@ -348,8 +361,8 @@ monochi SoftLowerLim -30.000000 monochi SoftUpperLim 30.000000 monochi Fixed -1.000000 monochi InterruptMode 0.000000 +monochi precision 0.010000 monochi AccessCode 2.000000 -run monochi 30.000000 # Motor monophi monophi sign 1.000000 monophi SoftZero 0.000000 @@ -357,8 +370,8 @@ monophi SoftLowerLim -30.000000 monophi SoftUpperLim 30.000000 monophi Fixed -1.000000 monophi InterruptMode 0.000000 +monophi precision 0.010000 monophi AccessCode 2.000000 -run monophi 30.000000 # Motor monoy monoy sign 1.000000 monoy SoftZero 0.000000 @@ -366,8 +379,8 @@ monoy SoftLowerLim -30.000000 monoy SoftUpperLim 30.000000 monoy Fixed -1.000000 monoy InterruptMode 0.000000 +monoy precision 0.010000 monoy AccessCode 2.000000 -run monoy 30.000000 # Motor monox monox sign 1.000000 monox SoftZero 0.000000 @@ -375,8 +388,8 @@ monox SoftLowerLim -30.000000 monox SoftUpperLim 30.000000 monox Fixed -1.000000 monox InterruptMode 0.000000 +monox precision 0.010000 monox AccessCode 2.000000 -run monox 30.000000 # Motor tasse tasse sign 1.000000 tasse SoftZero 0.000000 @@ -384,8 +397,8 @@ tasse SoftLowerLim -130.000000 tasse SoftUpperLim 130.000000 tasse Fixed -1.000000 tasse InterruptMode 0.000000 +tasse precision 0.010000 tasse AccessCode 2.000000 -run tasse 130.000000 # Motor sdm sdm sign 1.000000 sdm SoftZero 0.000000 @@ -393,8 +406,8 @@ sdm SoftLowerLim -5.000000 sdm SoftUpperLim 50.000000 sdm Fixed -1.000000 sdm InterruptMode 0.000000 +sdm precision 0.010000 sdm AccessCode 2.000000 -run sdm 27.500000 # Motor sgu sgu sign 1.000000 sgu SoftZero 0.000000 @@ -402,8 +415,8 @@ sgu SoftLowerLim -20.000000 sgu SoftUpperLim 20.000000 sgu Fixed -1.000000 sgu InterruptMode 0.000000 +sgu precision 0.010000 sgu AccessCode 2.000000 -run sgu 20.000000 # Motor sgl sgl sign 1.000000 sgl SoftZero 0.000000 @@ -411,8 +424,8 @@ sgl SoftLowerLim -20.000000 sgl SoftUpperLim 20.000000 sgl Fixed -1.000000 sgl InterruptMode 0.000000 +sgl precision 0.010000 sgl AccessCode 2.000000 -run sgl 20.000000 # Motor mgu mgu sign 1.000000 mgu SoftZero 0.000000 @@ -420,8 +433,8 @@ mgu SoftLowerLim -50.000000 mgu SoftUpperLim 50.000000 mgu Fixed -1.000000 mgu InterruptMode 0.000000 +mgu precision 0.010000 mgu AccessCode 2.000000 -run mgu 50.000000 # Motor stu stu sign 1.000000 stu SoftZero 0.000000 @@ -429,8 +442,8 @@ stu SoftLowerLim -30.000000 stu SoftUpperLim 30.000000 stu Fixed -1.000000 stu InterruptMode 0.000000 +stu precision 0.010000 stu AccessCode 2.000000 -run stu 30.000000 # Motor stl stl sign 1.000000 stl SoftZero 0.000000 @@ -438,8 +451,8 @@ stl SoftLowerLim -30.000000 stl SoftUpperLim 30.000000 stl Fixed -1.000000 stl InterruptMode 0.000000 +stl precision 0.010000 stl AccessCode 2.000000 -run stl 30.000000 # Motor mtu mtu sign 1.000000 mtu SoftZero 0.000000 @@ -447,8 +460,8 @@ mtu SoftLowerLim -30.000000 mtu SoftUpperLim 30.000000 mtu Fixed -1.000000 mtu InterruptMode 0.000000 +mtu precision 0.010000 mtu AccessCode 2.000000 -run mtu 30.000000 # Motor mtl mtl sign 1.000000 mtl SoftZero 0.000000 @@ -456,8 +469,8 @@ mtl SoftLowerLim -30.000000 mtl SoftUpperLim 30.000000 mtl Fixed -1.000000 mtl InterruptMode 0.000000 +mtl precision 0.010000 mtl AccessCode 2.000000 -run mtl 30.000000 # Motor a6 a6 sign 1.000000 a6 SoftZero 0.000000 @@ -465,8 +478,8 @@ a6 SoftLowerLim -30.000000 a6 SoftUpperLim 30.000000 a6 Fixed -1.000000 a6 InterruptMode 0.000000 +a6 precision 0.010000 a6 AccessCode 2.000000 -run a6 30.000000 # Motor a5 a5 sign 1.000000 a5 SoftZero 0.000000 @@ -474,8 +487,8 @@ a5 SoftLowerLim -30.000000 a5 SoftUpperLim 30.000000 a5 Fixed -1.000000 a5 InterruptMode 0.000000 +a5 precision 0.010000 a5 AccessCode 2.000000 -run a5 30.000000 # Motor a4 a4 sign 1.000000 a4 SoftZero 0.000000 @@ -483,8 +496,8 @@ a4 SoftLowerLim -130.000000 a4 SoftUpperLim 130.000000 a4 Fixed -1.000000 a4 InterruptMode 0.000000 +a4 precision 0.010000 a4 AccessCode 2.000000 -run a4 130.000000 # Motor a3 a3 sign 1.000000 a3 SoftZero -20.000000 @@ -492,8 +505,8 @@ a3 SoftLowerLim -340.000000 a3 SoftUpperLim 380.000000 a3 Fixed -1.000000 a3 InterruptMode 0.000000 +a3 precision 0.010000 a3 AccessCode 2.000000 -run a3 120.000000 # Motor a2 a2 sign 1.000000 a2 SoftZero 0.000000 @@ -501,8 +514,8 @@ a2 SoftLowerLim -73.000000 a2 SoftUpperLim 137.000000 a2 Fixed -1.000000 a2 InterruptMode 0.000000 +a2 precision 0.010000 a2 AccessCode 2.000000 -run a2 105.000000 # Motor a1 a1 sign 1.000000 a1 SoftZero 0.000000 @@ -510,8 +523,8 @@ a1 SoftLowerLim 15.000000 a1 SoftUpperLim 120.000000 a1 Fixed -1.000000 a1 InterruptMode 0.000000 +a1 precision 0.010000 a1 AccessCode 2.000000 -run a1 52.500000 user Uwe Filges user setAccess 2 sample D20 30K SNP Okt 2001 GS @@ -520,4 +533,3 @@ title endtest called with 23.000000 :Driving: title setAccess 2 starttime 2002-08-07 08:09:45 starttime setAccess 2 -Success diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 0086e838..0aec462f 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -38,6 +38,7 @@ Modified to work without counter in slave mode. Mark Koennecke, January 2001 + ----------------------------------------------------------------------------*/ #include #include diff --git a/tasutil.c b/tasutil.c index c6aaea9f..52e64002 100644 --- a/tasutil.c +++ b/tasutil.c @@ -428,6 +428,14 @@ int TASCalc(pTASdata self, SConnection *pCon, } readConversionFactors(self,helmconv); + /* + warning if energy fixed + */ + if(ifx == 0) + { + SCWrite(pCon,"WARNING: energy fixed",eWarning); + } + /* read a4 in order to make magnet calculations work */