| Header | Function | Example |
|---|---|---|
| RAT1 | CH1 Attenuator(-31〜0)読み込み | [要求]RAT1<CR><LF>[応答] AT1:-18<CR><LF> |
| RAT2 | CH2 Attenuator(-31〜0)読み込み | [要求]RAT2<CR><LF>[応答] AT2:-10<CR><LF> |
| RCH1 | CH1レベル読み込み | [要求]RCH1<CR><LF> [応答]CH1:-0.5,4005<CR><LF> |
| RCH2 | CH2レベル読み込み | [要求]RCH2<CR><LF> [応答]CH2:-10.2,305<CR><LF> |
| RINP | 位相差を比較する信号読み込み | [要求]RINP<CR><LF> [応答]INP:1,2<CR><LF> |
| RPHV | 位相差読み込み | [要求]RPHV<CR><LF> [応答]PHV:-10.35<CR><LF> |
| RREF | Refレベル読み込み | [要求]RREF<CR><LF> [応答]REF:-3.5,802<CR><LF> |
| RSAM | 平均回数読み込み | [要求]RSAM<CR><LF> [応答]SAM:1024<CR><LF> |
| RTEM | 恒温室温度読み込み | [要求]RTEM<CR><LF> [応答]TEM:32.5,258<CR><LF> |
| RVER | ソフトバージョン表示 | [要求]RVER<CR><LF> [応答]VER:1.01 2004/06/02 (142)<CR><LF> |
| SAT1 | CH1 Attenuator(-31〜0)設定 | [要求]SAT1:-17<CR><LF>[応答] AT1:-17<CR><LF> |
| SAT2 | CH2 Attenuator(-31〜0)設定 | [要求]SAT2:-10<CR><LF>[応答] AT2:-10<CR><LF> |
| SINP | 位相差を比較する信号設定 | [要求]SINP:1,2<CR><LF> [応答]INP:1,2<CR><LF> |
| SSAM | 平均回数設定 | [要求]SSAM:1024<CR><LF> [応答]SAM:1024<CR><LF> |
以下で使う、directory構造は次の通りとお思い願わしゅう存じます。
はじめに、abco1上でGDLファイルを作り、gdcでコンパイルします。
Linux PCのEPICS application directoryの所に、asynドライバーの中の、testGpibSerialAppの中のdevTestGpibSeal.cをコピーして、devB4phase.cとします。先ほど作ったファイルを使い、秘術を尽くして紆余曲折の結果編み出されたのが、本デバイスサポートです。
以下、変更のポイントを示します。
#define DSET_AI devAiB4phase #define DSET_AO devAoB4phase #define DSET_BI devBiB4phase #define DSET_BO devBoB4phase #define DSET_LI devLiB4phase #define DSET_LO devLoB4phase #define DSET_MBBO devMbboB4phase #define DSET_MBBI devMbbiB4phase #define DSET_SI devSiB4phase #define DSET_SO devSoB4phaseのように、使うEPICSレコードを定義します。
{&DSET_LI, GPIBREAD, IB_Q_LOW, "RAT1\r\n", "AT1:%ld\r\n", 0, 511, NULL, 0, 0, NULL, NULL, -1 },
のように-1になっていますが、これは間違い。EOSNLにしておいた方が良いです。
static long init_ai(int parm)
{
if(parm==0) {
devSupParms.name = "devB4phase";
devSupParms.gpibCmds = gpibCmds;
devSupParms.numparams = NUMPARAMS;
devSupParms.timeout = TIMEOUT;
devSupParms.timeWindow = TIMEWINDOW;
devSupParms.respond2Writes = 1.0;
}
return(0);
}
のように、respond2Writesの値を-1から適当な値(秒単位)に変えます。
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "SAT1:%ld\r\n", 511,511, NULL, 0, 0, NULL, NULL, EOSNL },
のように、readback buffer(コマンドの直後の数字)を用意します。
static int convAi(gpibDpvt *pdpvt, int P1, int P2, char **P3)
{
struct aiRecord *pai = ((struct aiRecord *)(pdpvt->precord));
char *craw;
char wa1[3000];
craw = pdpvt->msg;
craw = strtok(craw,":");
strcpy(wa1,strtok(NULL,","));
/* printf("data wa1 %s\n",wa1); */
pai->val = atof(wa1);
pai->udf = FALSE;
return 0;
}
のような、:のあとの数字を抜き出すfunctionを用意します。
#define CH1_CH2 "1,2"
#define CH1_CH3 "1,3"
#define CH2_CH3 "2,3"
static int convMi(gpibDpvt *pdpvt, int P1, int P2, char **P3)
{
struct longinRecord *pli = ((struct longinRecord *)(pdpvt->precord));
char *craw;
char wa1[3000];
craw = pdpvt->msg;
craw = strtok(craw,":");
strcpy(wa1,strtok(NULL,"\r"));
/* printf("input %s\n",wa1); */
if (strncmp(wa1,CH1_CH2,3)==0) {
pli->val = 0;
}
else if (strncmp(wa1,CH1_CH3,3)==0w) {
pli->val = 1;
}
else if (strncmp(wa1,CH2_CH3,3)==0) {
pli->val = 2;
}
else printf("error %s\n",wa1);
pli->udf = FALSE;
return 0;
}
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
ASYN = /local/R314.6/modules/soft/asyn/3-3
ASYN_LIB = /local/R314.6/modules/soft/asyn/3-3/lib/linux-x86
ASYN_BIN = /local/R314.6/modules/soft/asyn/3-3/bin/linux-x86
fblinux_DBD += fblinuxInclude.dbd
#============================
# Build an IOC support library
LIBRARY_IOC += FBsupport
# The following are compiled and added to the Support library
FBsupport_SRCS += devB4phase.c
FBsupport_LIBS += asyn
FBsupport_LIBS += $(EPICS_BASE_IOC_LIBS)
#=============================
# build an ioc application
PROD_IOC = fblinux
# fblinux.dbd will be created and installed
DBD += fblinux.dbd
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
fblinux_SRCS += fblinux_registerRecordDeviceDriver.cpp
fblinux_SRCS_DEFAULT += fblinuxMain.cpp
fblinux_SRCS_vxWorks += -nil-
# Add locally compiled object code
fblinux_SRCS += dbSubExample.c
# The following adds support from base/src/vxWorks
fblinux_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
fblinux_LIBS += FBsupport
# NOTE: To build SNL programs, SNCSEQ must be defined
# in the <top>/configure/RELEASE file
ifneq ($(SNCSEQ),)
# This builds sncExample as a component of fblinux
fblinux_DBD += sncExample.dbd
fblinux_SRCS += sncExample.stt
fblinux_LIBS += seq pv
# The following builds sncProgram as a standalone application
PROD_HOST += sncProgram
sncProgram_SNCFLAGS += +m
sncProgram_SRCS += sncProgram.st
sncProgram_LIBS += seq pv
sncProgram_LIBS += $(EPICS_BASE_HOST_LIBS)
endif
fblinux_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
| DTYP | Record | Signal | Name | Function | Remarks |
|---|---|---|---|---|---|
| NP_PS | longin | 0 | $(USER):PHASE:AT1:READ | ATT1読み込み | |
| NP_PS | longin | 1 | $(USER):PHASE:AT2:READ | ATT2読み込み | |
| NP_PS | ai | 2 | $(USER):PHASE:CH1:READ | CH1レベル読み込み | 2秒毎にスキャン |
| NP_PS | ai | 3 | $(USER):PHASE:CH2:READ | CH2レベル読み込み | 2秒毎にスキャン |
| NP_PS | mbbi | 4 | $(USER):PHASE:MIX:READ | Mixer入力読み込み | 使用不可 |
| NP_PS | ai | 5 | $(USER):PHASE:PS:READ | 位相差読み込み | 2秒毎にスキャン |
| NP_PS | ai | 6 | $(USER):PHASE:REF:READ | REFレベル読み込み | |
| NP_PS | longin | 7 | $(USER):PHASE:AVE:READ | 平均回数読み込み | |
| NP_PS | ai | 8 | $(USER):PHASE:TEMP:READ | 恒温槽温度読み込み | |
| NP_PS | stringin | 9 | $(USER):PHASE:VER:READ | ソフトバージョン読み込み | 後半部分は出てこない |
| NP_PS | longout | 10 | $(USER):PHASE:AT1:SET | ATT1設定 | |
| NP_PS | longout | 11 | $(USER):PHASE:AT2:SET | ATT2設定 | |
| NP_PS | mbbi | 12 | $(USER):PHASE:MIX:SET | Mixer入力設定 | 使用不可 |
| NP_PS | longout | 13 | $(USER):PHASE:AVE:SET | 平均回数設定 | |
| NP_PS | bo | 14 | $(USER):PHASE:INPUT:AB | Mix入力CH1-CH2設定 | MBBOの代替 |
| NP_PS | bo | 15 | $(USER):PHASE:INPUT:AC | Mix入力CH1-CH3設定 | MBBOの代替 |
| NP_PS | bo | 16 | $(USER):PHASE:INPUT:BC | Mix入力CH2-CH3設定 | MBBOの代替 |
| NP_PS | longin | 17 | $(USER):PHASE:INPUT:READ | MIX入力読み込み | 0=CH1-CH2,1=CH1-CH3,2=CH2-CH3 |
| Soft | mbbi | N/A | $(USER):PHASE:INPUT:SEL | Mixer入力読み込み |
ここで、データベースのディレクトリのMakefileも変更しておく必要があります。
TOP=../.. include $(TOP)/configure/CONFIG #---------------------------------------- # ADD MACRO DEFINITIONS AFTER THIS LINE #---------------------------------------------------- # Optimization of db files using dbst (DEFAULT: NO) #DB_OPT = YES #---------------------------------------------------- # Create and install (or just install) # databases, templates, substitutions like this #DB += dbExample1.db #DB += dbExample2.db #DB += dbSubExample.db DB += FB_TB4PHASE.db #---------------------------------------------------- # If <anyname>.db template is not named <anyname>*.template add # <anyname>_TEMPLATE = <templatename> include $(TOP)/configure/RULES #---------------------------------------- # ADD RULES AFTER THIS LINE