Hello,
I have some problems with the use
of the “asub” record. I’m trying to update a waveform record with two strings. So, my EPICS database looks like this:
record(waveform, "$(P):CRExeSeq") {
field(PINI, "NO")
field(DTYP, "Soft Channel")
field(UDF, "0")
field(NELM, "2")
field(FTVL, "STRING")
}
record(aSub, "$(P):_notifyCRExeSeq") {
field(SCAN, "Event")
field(EVNT, "4")
field(OUTA, "$(P):CRExeSeq")
field(SNAM, "asub_notify")
field(PINI, "NO")
field(FTVA, "STRING")
field(NOVA, "2")
field(NEVA, "2")
}
The “$(P):CRExeSeq” record is updated by the “$(P):_notifyCRExeSeq” record when an observer class executes the “post_event(4)” function. The problem is that my “asub_notify” function doesn’t really update the string
waveform. In this function, I process the update in the following way:
// I get the new informations from an other class
QStringList
l_infoAnotifier =
g_drvSequenceurMetier->getCRExecutionSequence();
//Here, I process the update
if(precord->nova
<= l_infoAnotifier.size()){
// I create a char**
char** l_info =
(char**)
malloc(l_infoAnotifier.size()*sizeof(char*));
for(int
i=0;i<l_infoAnotifier.size();i++){
l_info[i] = (char*)
malloc(40*sizeof(char));
if(l_infoAnotifier.at(i).length()<=40){
strcpy_s(l_info[i],40,l
l_infoAnotifier.at(i).toStdString().c_str());
}
else {
strcpy_s(l_info[i],40,"Error too much char");
}
}
//Copy
try {
char** l_stringout = (char**)
precord->vala;
memcpy_s(l_stringout,(40*precord->nova)*sizeof(char),
l_info,(40*l_infoAnotifier.size())*sizeof(char));
}
catch (...) {
printf("Error in the asub_notify function\n");
}
//Delete
delete[] l_info;
}
In the same way, I created a process function which seems to work for updating waveform of double-type data. Here, I think the problem comes from the string type and the “memcpy” functions.
Does anyone know how to realize asub functions for string waveforms? Or know why this code doesn’t work?
Ce message peut contenir des informations confidentielles dont la divulgation est à ce titre rigoureusement interdite en l'absence d'autorisation explicite de
l'émetteur. Dans l'hypothèse où vous auriez reçu par erreur ce message, merci de le renvoyer à l’émetteur et de détruire toute copie.
P Pensez à l’environnement avant d’imprimer.
|