LAMA是什么意思A在线翻译读音例句-张根硕的图片
2023年4月2日发(作者:深圳法语培训)
epics-ioc
HardwareLinksandDriverSupport
COLLABORATORS
TITLE:
HardwareLinksandDriverSupport
ACTIONNA不知深浅po1v2笔趣阁 MEDATESIGNATUREWRITTENBYMichaelDavidsaverSeptember2009
REVISIONHISTORY
NUMBERDATEDESCRIPTIONNAME
Contents
1Introduction1
2LinkingRecordsTogether13LinkingRecordsToHardware14WhenaHardwareLinkisNotEnough25DeviceSupport
PrivateData26DriverSupportandtheVirtualDevice37TheFullCrate38Example139Example2410Example35
11Example4(Full)5
11.1GlobalDe?nitions(5)
11.2DBD(6)
11.3IOCShellFunctions(6)
11.4DeviceSupport(8)
11.5DriverSupport(Uniform)(8)
11.6DriverSupport(Gaussian)(9)
ListofFigures
1AnExampleProcessDatabase(1)
ListofTables
1HardwareLinkTypes(2)
1Introduction
InanEPICScontrolsystemtheInputOutputController(IOC)isthenamegiventothepieceofsoftwarewhichsitsbetweenthe
netgercontrolsystemseesitasasetof
theIOCaChannelisrevealedtobeana?eldofaRecordintheProcess
Database,aProcessVariable(PV).lowsinformationto?
owbetweenRecordsswhentheyareprocessed.
ThisisthemilehighviewofanIOCandlacksseveralofthekeydetailswhichenableonetotakeanewpieceofhardware
ollowingdiscussionwewillstartattheProcessDatabaseandmovetowardsthe
mstobediscussedinclude:linkingtohardware,howtorepresentcomplexdevices,andtheFullCrate.
Figure1:AnExampleProcessDatabase
Inthedatabasepicturedabovethereare?ourPVsarelinkedtotwo
?fthPVmightbeofarecordtypewhichdoesnotneeddevicesupport,orwhichusessoft
devicesupport.
2LinkingRecordsTogether
‘kinds’arethosewhichlinktogethertworecords,and
eeclassesare:Input,Output,relinksareeitherInputor
Outputlinks.
Moreattentionisgiventothe?rstkindbecause
isthesecondhowever,whichwewillfocuson.
InFigure1anexampleoflinkingtworecordstogethercanbeseenbetweenthePVsA:1andA:uldbeaninputlink
byA:2topullthevalueofA:1,itcouldbeanoutputlinkbyA:1topushavalueintoA:2,oritcouldbeaforwardlinkbyA:1to
A:2.3LinkingRecordsToHardware
Hardwarelinksservetoassociatearecord’sdevicesupportwithaparticular(virtual)?gureabovePVA:2hasan
hardwareoutputlink,andA:3hasahardwareinputlink.
Unlikealinkbetweentworecords,endsonwhichphysicalmachineandIOC
venmeaningbythedevicesupport,sothesamehardwarelinkstringwillmeantwodifferentthings
whenusedwithtwodifferentdevicesupportsinthesameIOC.
TypeFieldformat
VME_IO‘#CxxSyy@zzz’
CAMAC_IO‘#BxxCyyNzzAttFuu@vvv’
AB_IO‘#LxxAyyCzzStt@uuu’
GPIB_IO‘#LxxAyy@zzz’
BITBUS_IO‘#LxxNyyPzzStt@uuu’
INST_IO‘@xxx’
BBGPIB_IO‘#LxxByyGzz@ttt’
RF_IO‘#RxxMyyDzzEtt’
VXI_IO‘#VxxCyySzz@ttt’
Table1:HardwareLinkTypes
The9allowedhardwarelinktypesarelistedintableTable1.
yareimplimented,andhowtheyareintendedtobeused.
AHWlinktypenameisjustalabelappliedtoonearmofaCunion(de?nedinlink.h).Forexample,aVME_IOlinkmightbe
written“#C0x4000S0x8@signed”.Thisisparsedandplacedintheappropriatearmoftheunion;whichisitselfaCstructure
withthreemembers:card,signal,?arsingno
allthatahardwarelinkis.
Thiscollectionocethereissomuch
variationinthewaydiffererentscheme
isatradeofftoremovesomeparsing(ieatoi())anderrorcheckingcodewhichwouldotherwisebereplicatedbyeverydevice
support,andmoveitintotheprocessdatabaseframework.
AlinktypelikeVME_IOissonamedbecauseitisoftenconvienenttothinkofaddressingavmecardbyslotnumberanda
function/channelcode,dsdonotneedtouseVME_IO
typelinksandGPI
BdevicesdonotneedtouseGPIB_ME_IOandGPIB_IOlinksstorethesamedata(twoshortintsanda
string)fferonlyinthenamesusedinthetwoarmsofthe
Cunion.
4WhenaHardwareLinkisNotEnough
Heaksdownwhentheinformationtobe
passedbe秋思翻译 comeslargeorwhenthereisinitializationtobeperformed.
Itisdif?culttohandleinitializationtasks,whichmusthappenonceandonlyonce,inahardwarelinkwhichisduplicatedin
mptingtothinkofgivingonerecorda‘special’linkwhichtellsdevicesupportwhentoinitialize,butthereis
reinitializationcanbedoneeasilyandcleanlyintheIOCShell.
AcommonpatternisforaDeviceSupporttoprovideanIOCShellfunctiontoacceptandpreprocesscomplexhardwaread-
forsupporthardwarelinks
passtheintegerkeytotheDeviceSupportforeachRecord,whichmustindividuallypreformalookuptoretrievethecomplete
okupisusuallydonetheDeviceSupportinit_pleofthisisgivenbelow
inSection9.
5DeviceSupportPrivateData
Theuseofhardwarelinksimpliessomesortoflookuptogetfromasetofshortintegersandastringtoapointertoamemory
mappeddevice,orasystem?ledescriptor/socketformessagebaseddevices.
Itwouldbeinef?sreasonthedevicesupportauthoris
providedwiththeDeviceSupportPrivate(dpvt)?eld,?eldisavoid*whichmaybeused
otbeaccessviaChannelAccess.
Itcouldbeusedtostorethe
commonlyitwillstoreapointertoastructurede?nedbythedevicesupportauthor.
6DriverSupportandtheVirtualDevice
EPICSDriverSupportisnotawellde?dbeanyofthefollowingamongothers:
Asetoffunctionssharedbetweenseveraldevicesupports.
InvolveIOCShellfunctionsforsetup.
AninterfacetoanOperatingSystemdriver.
The“of?cial”de?nitionofDriverSupportisintermsofthedrvetstructurede?ableoffunctionpointers
similartotheDeviceSupportdsettable.
Itprovidesawaytode?uldbeusedtoabstractawaythedifferences
betweenvarientsofacardorevenbusaccessmethod().Theabstractoperationspresentedbythisinterfaceto
DeviceSupportareessentuallya‘VirtualDevice’.
casestheextraabstractionitprovidesserveonlytoaddcomplexitywithnorealbeni?t.
Knowingwhentouseitisaskillwhichdevelopswithtime.
TheexampleSection11belowextendsthePRNGdevicesupportdevelopedintheBasicEPICSDeviceSuppo锈组词 rtdocument
todemonstrateacasewhereDriverSupportcanbeuseful.
7TheFullCrate
EPICSisadistributedcontrolsystemandmustbeabletoscalewell,bothinnumberofIOCsaswellasthesizeofanyoneof
theseIOCS.
TheconceptsofLinkingexiststoenforceisolationbetweenrecords(andassociatedDeviceSupports).Theideaisthatif
recordsinstancescanonlyinteractinwellunderstoodwaysthenitiseasiertoscaletoanarbitrarilylargenumberof
relinkingallowsthisisolationtobebrokentotheextentnecessarytodealtherealitywithcomplexdevices.
mple,?rstthatanADCcardhasachannel,then
thatithasmanychannels,and?portanttoconsiderthataDevice
SupportwillgointoanIOCwhichmanyhavemanyofitsdevices,andotherdeviceswhichitshouldnotinterferewith.
Conlresourcesbeallocated?What
baseaddressshouldeachcardbeassigned?Willall20cardsinterrupttheCPU(atthesametime)?Thesearethetypesof
questionswhichmustbeansweredtocreateanIOCwhichcanscale.
8Example1
ConsiderthefollowingaconcreteexampleoftheA:*PVsinthedatabaseillistratedin?gureFigure1.
Thehardwarespeci?cdevicesupportisde?nedinadatabasede?nition.
device(ao,GPIB_IO,devAoMine,\"MyDevice\")
device(ai,GPIB_IO,devAiMine,\"MyDevice\")
gavalueto0x04causesthevalueof0x08to
fthetypeGPIB_IOareusedtofurtherillustratethatthesenamesmeannothing.
ThedevicesupportdevAoMinetakesthesumofthetwointegerpartsofthehardwarelinkandusesthisastheVMEaddress
mstringisusedtoholdoptionalmodi?ers.
TherecordA:1existstoprovideaseperatelinearscalingforthesetting.
TheforwardlinkbetweenA:2andA:3causesthe0x8registertobereadafterthe0x4registeriswritten.
record(ao,\"A:1\"){
field(DTYP,\"SoftChannel\")
field(OUT,\"A:2\")
field(PINI,\"Yes\")
field(UDF,0)
field(VAL,4.2)
field(CONV,\"Linear\")
field(ESLO,-2.0)
field(EOFF,1.0)
field(EGU,\"mm\")
field(FLNK,\"A:2\")
}
record(ao,\"A:2\"){
field(DTYP,\"MyDevice\")
field(OUT,\"#L0x4000A0x04@signed\")
field(FLNK,\"A:3\")
}
record(ai,\"A:3\"){
field(DTYP,\"MyDevice\")
field(OUT,\"#L0x4000A0x08@signed\")
}
9Example2
icesupportwritermakesthedecisiontocreateanIOCShell
functioncalledinitMyDev(int,int,string)andaddsittotheIOCstartscript.
dbLoadDatabase(\"dbd/\")
mydevioc_registerRecordDeviceDriver(pdbase)
initMyDev(0,0x4000,\"signed\")
dbLoadRecords(\"db/\",\"prefix=A:,card=0\")
iocInit()
ThisassociatestheVMEcardwiththeA16baseaddress0x4000withtheintegerkey0,whichispassedas$(card)whenthe
recordsareloaded.
Thedatabasethenbecomesthefollowing:
record(ao,\"$(prefix)1\"){
field(DTYP,\"SoftChannel\")
field(OUT,\"A:2\")
field(PINI,\"Yes\")
field(UDF,0)
field(VAL,4.2)
field(CONV,\"Linear\")
field(ESLO,-2.0)
field(EOFF,1.0)
field(EGU,\"mm\")
field(FLNK,\"A:2\")
}
record(ao,\"$(prefix)2\"){
field(DTYP,\"MyDevice\")
field(OUT,\"#L$(card)A0x04@\")
field(FLNK,\"A:3\")
}
record(ai,\"$(prefix)3\"){
field(DTYP,\"MyDevice\")
field(OUT,\"#L$(card)A0x08@\")
}
Itthissimpleexamplewedonotgainmuchforthetrouble,butthisapproachis?exibleinawaythathardwarelinksaloneare
not.
10Example3
ychangerequiredisintheIOCstartscript.
dbLoadDatabase(春望写作背景 \"dbd/\")
mydevioc_registerRecordDeviceDriver(pdbase)
initMyDev(0,0x4000,\"signed\")
i贫贱夫妻百事哀上下联 nitMyDev(1,0x5000,\"signed\")
initMyDev(2,0x6000,\"signed\")
initMyDev(3,0x7000,\"signed\")
initMyDev(4,0x8000,\"signed\")
dbLoadRecords(\"db/\",\"prefix=A:,card=0\")
dbLoadRecords(\"db/\",\"prefix=B:,card=1\")
dbLoadRecords(\"db/\",\"prefix=C:,card=2\")
dbLoadRecords(\"db/\",\"prefix=D:,card=3\")
dbLoadRecords(\"db/\",\"prefix=E:,card=4\")
iocInit()
Thiswillcreate?vecopiesofthePVsde?nedindb/,eachwithadifferentpre?xcommunicatingwithadifferentcard.
Thefactthatthiscanbedonewithoutmodifying(orevenrecompiling)anyoftheDeviceSupportcodeiswhatallowsan
EPICSIOCtoquicklyandeasilyscaletolargenumbersofdevices.
11Example4(Full)
icesupportforthepseudo-randomnumbergenerator
developedintheBasicversinthis
casewillbeusedtoselectbetweentwopossiblerandomnumberdistributions.
11.1GlobalDe?nitions
Webeginbyde?the‘VirtualDevice’casewe
haveonlytwooperations:ateoperationreferstocreatinga‘VirtualDevice’,andcouldalsobenamed
nd.
The‘hardwareaddress’d*returnedbythe
createfunctionmustbeusedwhenthereadfunctioniscalled,interis
effectivelythethispointerofC++.
Thefollowingcodeshouldbeplacedinthe?leprngApp/src/drvprngdist.h.
typedefvoid*(*create_prng_fun)(unsignedintseed);
typedefint(*read_prng_fun)(void*tok);
structdrvPrngDist{
drvetbase;
create_prng_funcreate_prng;
read_prng_funread_prng;
};
Thisde?nitionmustbesharedbetweentheDriverSupportcodeandtheDeviceSupport(s)whichwilluseit.
Nowwede?neanadditionalstructurewhichcanbethoughofasthepublicdatamembersofthedrvPrngDistclass.
structinstancePrng{
ELLNODEnode;/*mustbefirst*/
structdrvPrngDist*table;
void*token;
intid;
};
AELLNODEisalsoincludedasaconvinienceforthelookupPrngfunction;whichwillbeusedbyDeviceSupporttolocatea
speci?cinstanceofdrvPrngDistbasedontheidnumberpassedtoitinahardwarelink.
structinstancePrng*lookupPrng(shortN);
11.2DBD
Atthispointweshouldcreatethedatabasede?nitionasprngApp/src/.
device(ai,VME_IO,devAiPrngDist,\"RandomDistribution\")
driver(drvPrngUniform)
driver(drvPrngGaussian)
registrar(prngDist)
11.3IOCShellFunctions
CreatinginstanceofPRNG‘VirtualDevices’willbeaccomplishedwithanIOCShellfunctioncalledcreatePrnginthe?le
staticELLLISTdevices={{NULL,NULL},0};
staticconstchardpref[]=\"drv凤求凰司马相如 Prng\";
Herewede?nealistwhichwillholdallcreateddeviceinstancesandthepre?xforDriverSupportnames(asseeninthe
dbd).void
createPrng(intid,intseed,constchar*dist)
{
unsignedints=(unsignedint)seed;
char*dname=NULL;
size_范晔的作品 tdlen;
structinstancePrng*inst=malloc(sizeof(structinstancePrng));
if(!inst){
epicsPrintf(\"OutofMemoryn\");
gotoerror;
}
/*sizeof(dpreg)==strlen(dpref)+1*/
dlen=sizeof(dpref)+strlen(dist);
dname=malloc(dlen);
if(!dname){
epicsPrintf(\"OutofMemoryn\");
gotoerror;
}
strcpy(dname,dpref);
strcat(dname,dist);
SomeboilerplateforallocationandconstructionoftheDriverSupportnamestring.
inst->table=(structdrvPrngDist*)registryDriverSupportFind(dname);
if(!inst->table){
epicsPrintf(\"UnknownDistributiontypen\");
gotoerror;
}
WhenaDriverSupportisregisteredwitharunningIOCitsnameisplacedinalistwhichcanbequeriedwiththe
waythedistargumentisusedtoselectwhichDriverSupportistobeused.
SincethetwoDriverSupportsarecalleddrvPrngUniformanddrvPrngGaussianthetwovalidvaluesforthedistargumentare
‘Uniform’and‘Gaussian’.
inst->token=inst->table->create_prng(s);
if(!inst->token){
epicsPrintf(\"FailedtocreatePRNG.n\");
gotoerror;
}
TheDriverSupportcreatefunctionisusedtocreateanewinstancetoken.
inst->id=id;
e旷日持久是贬义词吗 llAdd(&devices,&inst->node);
return;
error:
free(dname);
free(inst);
return;
}
Allthatremainsistoaddtheinstancetothedeviceslistsothelookupfunctioncan?ndit.
atesthroughthelistofinstancesuntilit?ndsamatch.
structinstancePrng*lookupPrng(shortN)
{
ELLNODE*node;
structinstancePrng*ent;
for(node=ellFirst(&devices);node;node=ellNext(node)){
ent=(structinstancePrng*)node;/*UseCONTAINER()in3.14.11*/
if(ent->id==N)
returnent;
}
returnNULL;
}
11.4DeviceSupport
NowweturntotheDeviceSupportfunctionsfortheAIrecordtype(prngApp/src/devprngdist.c).Inthiscasetheinit_recordand
read_lythiswouldbeasignthatthetaskistoo
simpletobeni?tfromDriverSupportandsuggeststhatweinsteadcreatetwodifferentDeviceSupports.
staticlonginit_record(aiRecord*pao)
{
structinstancePrng*priv;
priv=lookupPrng(pao->);
if(!priv){
recGblRecordError(S_dev_noDevice,(void*)pao,
\"Notavaliddeviceidcode\");
returnS_dev_noDevice;
}
pao->dpvt=priv;
return0;
}
HereweusethelookupPrngfunctionwith(partof)ecardvalueisusedbecausenothingmoreis
needed.
IffoundtheinstanceisstoredintheDeviceSupportPrivate?eldforfutureuse.
staticlongread_ai(aiReco李清照的词一剪梅 rd*pao)
{
structinstancePrng*priv=pao->dpvt;
pao->rval=priv->table->read_prng(priv->token);
return0;
}
Toreadarandomnumberweusethereadfunctioninthefunctiontablestoredwiththeinstanceandpassittheinstance
tokenwhichwascreatedwiththecreatefunctionalsointhistable.
11.5DriverSupport(Uniform)
Wewillde??rstwillgeneraterandomnumbersinauniformdistribution(prngApp/src/drvprngu-
nif.c).
structuniform{
unsignedintstate;
};
Firstwede?effectivelytheprivatedataofthedrvPrngDist
ertothisstructurewillactastheinstance‘token’.
static
void*create(unsignedintseed)
{
structuniform*priv=malloc(sizeof(structuniform));
if(!priv)
returnNULL;
priv->state=seed;
returnpriv;
}
static
intread(void*tok)
{
structuniform*priv=tok;
returnrand_r(&priv->state);
}
static
structdrvPrngDistdrvPrngUniform={
{4,
NULL,
NULL,
},
create,
read,
};
epicsExportAddress(drvet,drvPrngUniform);
Theactualde?nitionofthisDriverSupportisstraightforward.
11.6DriverSupport(Gaussian)
WhilethedifferencebetweentheGaussianandUniformgeneratorsissmalltheyareplacedinseperate?lestodemonstrate
thatthetwoDriverSupportscanbecompletelyisolatedfromeachother.
structgaussian{
unsignedintstate;
};
static
void*create(unsignedintseed)
{
structgaussian*priv=malloc(sizeof(structgaussian));
if(!priv)
returnNULL;
priv->state=seed;
returnpriv;
}
static
intread(void*tok)
{
structgaussian*priv=tok;
intret=0,i=8;
while(i--)
ret+=rand_r(&priv->state)/8;
returnret;
}
ToapproximateaGaussiandistribution,severaluniformrandomnumbersaresummedinaccordancewiththeCentralLimit
Theorem.
static
structdrvPrngDistdrvPrngGaussian={{4,
NULL,
NULL,
},
create,
read,
};
epicsExportAddress(drvet,drvPrngGaussian);
更多推荐
epics是什么意思cs在线翻译读音例句
发布评论