1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 <2024> 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 <2024> 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Help trying to pass std::vectors as areaDetector attributes |
From: | Marco Filho via Tech-talk <tech-talk at aps.anl.gov> |
To: | "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Cc: | George Kontogiorgos <george.kontogiorgos at ess.eu> |
Date: | Wed, 18 Sep 2024 15:10:49 +0000 |
Good afternoon all. pArray->pAttributeList->add("Even Cooler Attribute", "Description", NDAttrUInt64, &MyAttrVal); // Passing the address to the actual vector...
// Driver then doCallbacksGenericPointer, etc.################################ IN PLUGIN ################################ //Inside processCallbacks...
NDAttribute * pToAttr = pArray.pAttributeList->find("Even Cooler Attribute"); std::vector<uint32_t> pAttrVec; pToAttr->getValue(NDAttrUInt64, &pAttrVec); //Address to actual vector... // Do vector stuff... ################################ case NDAttrUInt64:
this->value_.ui64 = *(epicsUInt64 *)pValue; And then things blow up because casting back from this to vector doesn't make sense. Well, we are left with three options, in order of my personal preference: 1- Try to add vector as attributes in ADCore. Would this be a welcome PR in the community? Does it make sense given the framework's way of operation? 2 - Add a second address to the driver, put the vectors data inside an NDArray as a generic pointer and pass it to the plugins. I don't like this, since it creates a customized structure that is not actually what an array is supposed to be. But it solves this problem... 3 - Poke around the casting made by pAttributeList->add() and similars to see if any of those would actually give my vector back. Feels ugly and catastrophic, but might work? Did anyone else try to do something similar? Is there any other way to do this? Is a PR that does this welcome in the community? Thanks for any help and discussions. Cheers, Marco |