renamed isSet to isWrite
This commit is contained in:
@@ -544,7 +544,7 @@ result_t BusHandler::handleSymbol()
|
|||||||
m_nextSendPos = 0;
|
m_nextSendPos = 0;
|
||||||
m_repeat = false;
|
m_repeat = false;
|
||||||
Message* message = m_messages->find(m_command);
|
Message* message = m_messages->find(m_command);
|
||||||
if (message == NULL || message->isPassive() == false || message->isSet() == true)
|
if (message == NULL || message->isPassive() == false || message->isWrite() == true)
|
||||||
return setState(bs_skip, RESULT_ERR_INVALID_ARG); // don't know this request or definition has wrong direction, deny
|
return setState(bs_skip, RESULT_ERR_INVALID_ARG); // don't know this request or definition has wrong direction, deny
|
||||||
|
|
||||||
// build response and store in m_response for sending back to requesting master
|
// build response and store in m_response for sending back to requesting master
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void printErrorPos(vector<string>::iterator begin, const vector<string>::iterato
|
|||||||
result_t DataField::create(vector<string>::iterator& it,
|
result_t DataField::create(vector<string>::iterator& it,
|
||||||
const vector<string>::iterator end,
|
const vector<string>::iterator end,
|
||||||
DataFieldTemplates* templates,
|
DataFieldTemplates* templates,
|
||||||
DataField*& returnField, const bool isSetMessage,
|
DataField*& returnField, const bool isWriteMessage,
|
||||||
const unsigned char dstAddress)
|
const unsigned char dstAddress)
|
||||||
{
|
{
|
||||||
vector<SingleDataField*> fields;
|
vector<SingleDataField*> fields;
|
||||||
@@ -175,11 +175,11 @@ result_t DataField::create(vector<string>::iterator& it,
|
|||||||
|
|
||||||
hasPartStr = partStr[0] != 0;
|
hasPartStr = partStr[0] != 0;
|
||||||
if (dstAddress == BROADCAST || isMaster(dstAddress) == true
|
if (dstAddress == BROADCAST || isMaster(dstAddress) == true
|
||||||
|| (isSetMessage == true && hasPartStr == false)
|
|| (isWriteMessage == true && hasPartStr == false)
|
||||||
|| strcasecmp(partStr, "M") == 0) { // master data
|
|| strcasecmp(partStr, "M") == 0) { // master data
|
||||||
partType = pt_masterData;
|
partType = pt_masterData;
|
||||||
}
|
}
|
||||||
else if ((isSetMessage == false && hasPartStr == false)
|
else if ((isWriteMessage == false && hasPartStr == false)
|
||||||
|| strcasecmp(partStr, "S") == 0) { // slave data
|
|| strcasecmp(partStr, "S") == 0) { // slave data
|
||||||
partType = pt_slaveData;
|
partType = pt_slaveData;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -139,14 +139,14 @@ public:
|
|||||||
* @param end the iterator pointing to the end of the definition parts.
|
* @param end the iterator pointing to the end of the definition parts.
|
||||||
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
|
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
|
||||||
* @param returnField the variable in which to store the created instance.
|
* @param returnField the variable in which to store the created instance.
|
||||||
* @param isSetMessage whether the field is part of a set message (default false).
|
* @param isWriteMessage whether the field is part of a write message (default false).
|
||||||
* @param dstAddress the destination bus address (default @a SYN for creating a template @a DataField).
|
* @param dstAddress the destination bus address (default @a SYN for creating a template @a DataField).
|
||||||
* @return @a RESULT_OK on success, or an error code.
|
* @return @a RESULT_OK on success, or an error code.
|
||||||
* Note: the caller needs to free the created instance.
|
* Note: the caller needs to free the created instance.
|
||||||
*/
|
*/
|
||||||
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
|
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
|
||||||
DataFieldTemplates* templates, DataField*& returnField,
|
DataFieldTemplates* templates, DataField*& returnField,
|
||||||
const bool isSetMessage=false, const unsigned char dstAddress=SYN);
|
const bool isWriteMessage=false, const unsigned char dstAddress=SYN);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the length of this field (or contained fields) in bytes.
|
* @brief Returns the length of this field (or contained fields) in bytes.
|
||||||
@@ -235,7 +235,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A single DataField.
|
* @brief A single @a DataField holding a value.
|
||||||
*/
|
*/
|
||||||
class SingleDataField : public DataField
|
class SingleDataField : public DataField
|
||||||
{
|
{
|
||||||
|
|||||||
+17
-17
@@ -32,12 +32,12 @@ using namespace std;
|
|||||||
/** the bit mask of the source master number in the message key. */
|
/** the bit mask of the source master number in the message key. */
|
||||||
#define ID_SOURCE_MASK (0x1fLL << (8 * 7))
|
#define ID_SOURCE_MASK (0x1fLL << (8 * 7))
|
||||||
|
|
||||||
Message::Message(const string clazz, const string name, const bool isSet,
|
Message::Message(const string clazz, const string name, const bool isWrite,
|
||||||
const bool isPassive, const string comment,
|
const bool isPassive, const string comment,
|
||||||
const unsigned char srcAddress, const unsigned char dstAddress,
|
const unsigned char srcAddress, const unsigned char dstAddress,
|
||||||
const vector<unsigned char> id, DataField* data,
|
const vector<unsigned char> id, DataField* data,
|
||||||
const unsigned int pollPriority)
|
const unsigned int pollPriority)
|
||||||
: m_class(clazz), m_name(name), m_isSet(isSet),
|
: m_class(clazz), m_name(name), m_isWrite(isWrite),
|
||||||
m_isPassive(isPassive), m_comment(comment),
|
m_isPassive(isPassive), m_comment(comment),
|
||||||
m_srcAddress(srcAddress), m_dstAddress(dstAddress),
|
m_srcAddress(srcAddress), m_dstAddress(dstAddress),
|
||||||
m_id(id), m_data(data), m_pollPriority(pollPriority),
|
m_id(id), m_data(data), m_pollPriority(pollPriority),
|
||||||
@@ -55,10 +55,10 @@ Message::Message(const string clazz, const string name, const bool isSet,
|
|||||||
m_key = key;
|
m_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message(const bool isSet, const bool isPassive,
|
Message::Message(const bool isWrite, const bool isPassive,
|
||||||
const unsigned char pb, const unsigned char sb,
|
const unsigned char pb, const unsigned char sb,
|
||||||
DataField* data)
|
DataField* data)
|
||||||
: m_class(), m_name(), m_isSet(isSet),
|
: m_class(), m_name(), m_isWrite(isWrite),
|
||||||
m_isPassive(isPassive), m_comment(),
|
m_isPassive(isPassive), m_comment(),
|
||||||
m_srcAddress(SYN), m_dstAddress(SYN),
|
m_srcAddress(SYN), m_dstAddress(SYN),
|
||||||
m_data(data), m_pollPriority(0),
|
m_data(data), m_pollPriority(0),
|
||||||
@@ -91,7 +91,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
{
|
{
|
||||||
// [type],[class],name,[comment],[QQ],[ZZ],id,fields...
|
// [type],[class],name,[comment],[QQ],[ZZ],id,fields...
|
||||||
result_t result;
|
result_t result;
|
||||||
bool isSet = false, isPassive = false;
|
bool isWrite = false, isPassive = false;
|
||||||
string defaultName;
|
string defaultName;
|
||||||
unsigned int pollPriority = 0;
|
unsigned int pollPriority = 0;
|
||||||
size_t defaultPos = 1;
|
size_t defaultPos = 1;
|
||||||
@@ -114,12 +114,12 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
defaultName = str;
|
defaultName = str;
|
||||||
}
|
}
|
||||||
else if (strncasecmp(str, "W", 1) == 0) { // active set
|
else if (strncasecmp(str, "W", 1) == 0) { // active set
|
||||||
isSet = true;
|
isWrite = true;
|
||||||
defaultName = str;
|
defaultName = str;
|
||||||
}
|
}
|
||||||
else { // any other: passive set/get
|
else { // any other: passive set/get
|
||||||
isPassive = true;
|
isPassive = true;
|
||||||
isSet = strcasecmp(str+len-1, "W") == 0; // if type ends with "w" it is treated as passive set
|
isWrite = strcasecmp(str+len-1, "W") == 0; // if type ends with "w" it is treated as passive set
|
||||||
defaultName = str;
|
defaultName = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,11 +239,11 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DataField* data = NULL;
|
DataField* data = NULL;
|
||||||
result = DataField::create(it, realEnd, templates, data, isSet, dstAddress==SYN ? ESC : dstAddress);
|
result = DataField::create(it, realEnd, templates, data, isWrite, dstAddress==SYN ? ESC : dstAddress);
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
returnValue = new Message(clazz, name, isSet, isPassive, comment, srcAddress, dstAddress, id, data, pollPriority);
|
returnValue = new Message(clazz, name, isWrite, isPassive, comment, srcAddress, dstAddress, id, data, pollPriority);
|
||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
|
|||||||
|
|
||||||
result_t Message::prepareSlave(SymbolString& slaveData)
|
result_t Message::prepareSlave(SymbolString& slaveData)
|
||||||
{
|
{
|
||||||
if (m_isPassive == false || m_isSet == true)
|
if (m_isPassive == false || m_isWrite == true)
|
||||||
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||||
|
|
||||||
SymbolString slave;
|
SymbolString slave;
|
||||||
@@ -366,10 +366,10 @@ result_t MessageMap::add(Message* message)
|
|||||||
return RESULT_ERR_DUPLICATE; // duplicate key
|
return RESULT_ERR_DUPLICATE; // duplicate key
|
||||||
}
|
}
|
||||||
bool isPassive = message->isPassive();
|
bool isPassive = message->isPassive();
|
||||||
bool isSet = message->isSet();
|
bool isWrite = message->isWrite();
|
||||||
string clazz = strtolower(message->getClass());
|
string clazz = strtolower(message->getClass());
|
||||||
string name = strtolower(message->getName());
|
string name = strtolower(message->getName());
|
||||||
string nameKey = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
|
string nameKey = string(isPassive ? "P" : (isWrite ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
|
||||||
map<string, Message*>::iterator nameIt = m_messagesByName.find(nameKey);
|
map<string, Message*>::iterator nameIt = m_messagesByName.find(nameKey);
|
||||||
if (nameIt != m_messagesByName.end()) {
|
if (nameIt != m_messagesByName.end()) {
|
||||||
return RESULT_ERR_DUPLICATE; // duplicate key
|
return RESULT_ERR_DUPLICATE; // duplicate key
|
||||||
@@ -380,7 +380,7 @@ result_t MessageMap::add(Message* message)
|
|||||||
if (isPassive == true)
|
if (isPassive == true)
|
||||||
m_passiveMessageCount++;
|
m_passiveMessageCount++;
|
||||||
|
|
||||||
nameKey = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + name; // also store without class
|
nameKey = string(isPassive ? "-P" : (isWrite ? "-W" : "-R")) + name; // also store without class
|
||||||
nameIt = m_messagesByName.find(nameKey);
|
nameIt = m_messagesByName.find(nameKey);
|
||||||
if (nameIt == m_messagesByName.end()) {
|
if (nameIt == m_messagesByName.end()) {
|
||||||
m_messagesByName[nameKey] = message; // only store first key without class
|
m_messagesByName[nameKey] = message; // only store first key without class
|
||||||
@@ -428,16 +428,16 @@ result_t MessageMap::addFromFile(vector<string>::iterator& begin, const vector<s
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message* MessageMap::find(const string& clazz, const string& name, const bool isSet, const bool isPassive)
|
Message* MessageMap::find(const string& clazz, const string& name, const bool isWrite, const bool isPassive)
|
||||||
{
|
{
|
||||||
string lclass = strtolower(clazz);
|
string lclass = strtolower(clazz);
|
||||||
string lname = strtolower(name);
|
string lname = strtolower(name);
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
string key;
|
string key;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
key = string(isPassive ? "P" : (isSet ? "W" : "R")) + lclass + FIELD_SEPARATOR + lname;
|
key = string(isPassive ? "P" : (isWrite ? "W" : "R")) + lclass + FIELD_SEPARATOR + lname;
|
||||||
else if (clazz.length() == 0)
|
else if (clazz.length() == 0)
|
||||||
key = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + lname; // second try: without class
|
key = string(isPassive ? "-P" : (isWrite ? "-W" : "-R")) + lname; // second try: without class
|
||||||
else
|
else
|
||||||
continue; // not allowed without class
|
continue; // not allowed without class
|
||||||
map<string, Message*>::iterator it = m_messagesByName.find(key);
|
map<string, Message*>::iterator it = m_messagesByName.find(key);
|
||||||
@@ -478,7 +478,7 @@ deque<Message*> MessageMap::findAll(const string& clazz, const string& name, con
|
|||||||
if (withPassive == false)
|
if (withPassive == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (message->isSet() == true) {
|
else if (message->isWrite() == true) {
|
||||||
if (withWrite == false)
|
if (withWrite == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -46,7 +46,7 @@ public:
|
|||||||
* @brief Construct a new instance.
|
* @brief Construct a new instance.
|
||||||
* @param clazz the optional device class.
|
* @param clazz the optional device class.
|
||||||
* @param name the message name (unique within the same class and type).
|
* @param name the message name (unique within the same class and type).
|
||||||
* @param isSet whether this is a set message.
|
* @param isWrite whether this is a write message.
|
||||||
* @param isPassive true if message can only be initiated by a participant other than us,
|
* @param isPassive true if message can only be initiated by a participant other than us,
|
||||||
* false if message can be initiated by any participant.
|
* false if message can be initiated by any participant.
|
||||||
* @param comment the comment.
|
* @param comment the comment.
|
||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
* @param data the @a DataField for encoding/decoding the message.
|
* @param data the @a DataField for encoding/decoding the message.
|
||||||
* @param pollPriority the priority for polling, or 0 for no polling at all.
|
* @param pollPriority the priority for polling, or 0 for no polling at all.
|
||||||
*/
|
*/
|
||||||
Message(const string clazz, const string name, const bool isSet,
|
Message(const string clazz, const string name, const bool isWrite,
|
||||||
const bool isPassive, const string comment,
|
const bool isPassive, const string comment,
|
||||||
const unsigned char srcAddress, const unsigned char dstAddress,
|
const unsigned char srcAddress, const unsigned char dstAddress,
|
||||||
const vector<unsigned char> id, DataField* data,
|
const vector<unsigned char> id, DataField* data,
|
||||||
@@ -64,14 +64,14 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new temporary instance.
|
* @brief Construct a new temporary instance.
|
||||||
* @param isSet whether this is a set message.
|
* @param isWrite whether this is a write message.
|
||||||
* @param isPassive true if message can only be initiated by a participant other than us,
|
* @param isPassive true if message can only be initiated by a participant other than us,
|
||||||
* false if message can be initiated by any participant.
|
* false if message can be initiated by any participant.
|
||||||
* @param pb the primary ID byte.
|
* @param pb the primary ID byte.
|
||||||
* @param sb the secondary ID byte.
|
* @param sb the secondary ID byte.
|
||||||
* @param data the @a DataField for encoding/decoding the message.
|
* @param data the @a DataField for encoding/decoding the message.
|
||||||
*/
|
*/
|
||||||
Message(const bool isSet, const bool isPassive,
|
Message(const bool isWrite, const bool isPassive,
|
||||||
const unsigned char pb, const unsigned char sb,
|
const unsigned char pb, const unsigned char sb,
|
||||||
DataField* data);
|
DataField* data);
|
||||||
|
|
||||||
@@ -107,10 +107,10 @@ public:
|
|||||||
string getName() const { return m_name; }
|
string getName() const { return m_name; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get whether this is a set message.
|
* @brief Get whether this is a write message.
|
||||||
* @return whether this is a set message.
|
* @return whether this is a write message.
|
||||||
*/
|
*/
|
||||||
bool isSet() const { return m_isSet; }
|
bool isWrite() const { return m_isWrite; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get whether message can be initiated only by a participant other than us.
|
* @brief Get whether message can be initiated only by a participant other than us.
|
||||||
@@ -225,8 +225,8 @@ private:
|
|||||||
/** the message name (unique within the same class and type). */
|
/** the message name (unique within the same class and type). */
|
||||||
const string m_name;
|
const string m_name;
|
||||||
|
|
||||||
/** whether this is a set message. */
|
/** whether this is a write message. */
|
||||||
const bool m_isSet;
|
const bool m_isWrite;
|
||||||
|
|
||||||
/** true if message can only be initiated by a participant other than us,
|
/** true if message can only be initiated by a participant other than us,
|
||||||
* false if message can be initiated by any participant. */
|
* false if message can be initiated by any participant. */
|
||||||
@@ -315,12 +315,12 @@ public:
|
|||||||
* @brief Find the @a Message instance for the specified class and name.
|
* @brief Find the @a Message instance for the specified class and name.
|
||||||
* @param clazz the optional device class.
|
* @param clazz the optional device class.
|
||||||
* @param name the message name.
|
* @param name the message name.
|
||||||
* @param isSet whether this is a set message.
|
* @param isWrite whether this is a write message.
|
||||||
* @param isPassive whether this is a passive message.
|
* @param isPassive whether this is a passive message.
|
||||||
* @return the @a Message instance, or NULL.
|
* @return the @a Message instance, or NULL.
|
||||||
* Note: the caller may not free the returned instance.
|
* Note: the caller may not free the returned instance.
|
||||||
*/
|
*/
|
||||||
Message* find(const string& clazz, const string& name, const bool isSet, const bool isPassive=false);
|
Message* find(const string& clazz, const string& name, const bool isWrite, const bool isPassive=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Find all active get @a Message instances for the specified class and name.
|
* @brief Find all active get @a Message instances for the specified class and name.
|
||||||
|
|||||||
Reference in New Issue
Block a user