Open Session - Invoke modifyPort RPC only if required
This commit is contained in:
parent
3090b5eebd
commit
f626c179aa
@ -454,6 +454,40 @@ void Port::getModifiedDeviceGroupsSinceLastSync(
|
|||||||
->CopyFrom(*deviceGroupById(id));
|
->CopyFrom(*deviceGroupById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Finds the user modifiable fields in 'config' that are different from
|
||||||
|
* the current configuration on the port and modifes 'config' such that
|
||||||
|
* only those fields are set and returns true. If 'config' is same as
|
||||||
|
* current port config, 'config' is unmodified and false is returned
|
||||||
|
*/
|
||||||
|
bool Port::modifiablePortConfig(OstProto::Port &config) const
|
||||||
|
{
|
||||||
|
bool change = false;
|
||||||
|
OstProto::Port modCfg;
|
||||||
|
|
||||||
|
if (config.is_exclusive_control() != d.is_exclusive_control()) {
|
||||||
|
modCfg.set_is_exclusive_control(config.is_exclusive_control());
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
if (config.transmit_mode() != d.transmit_mode()) {
|
||||||
|
modCfg.set_transmit_mode(config.transmit_mode());
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
if (config.user_name() != d.user_name()) {
|
||||||
|
modCfg.set_user_name(config.user_name());
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (change) {
|
||||||
|
modCfg.mutable_port_id()->set_id(id());
|
||||||
|
config.CopyFrom(modCfg);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Port::when_syncComplete()
|
void Port::when_syncComplete()
|
||||||
{
|
{
|
||||||
//reorderStreamsByOrdinals();
|
//reorderStreamsByOrdinals();
|
||||||
|
@ -155,6 +155,8 @@ public:
|
|||||||
void getModifiedDeviceGroupsSinceLastSync(
|
void getModifiedDeviceGroupsSinceLastSync(
|
||||||
OstProto::DeviceGroupConfigList &streamConfigList);
|
OstProto::DeviceGroupConfigList &streamConfigList);
|
||||||
|
|
||||||
|
bool modifiablePortConfig(OstProto::Port &config) const;
|
||||||
|
|
||||||
void when_syncComplete();
|
void when_syncComplete();
|
||||||
|
|
||||||
void setAveragePacketRate(double packetsPerSec);
|
void setAveragePacketRate(double packetsPerSec);
|
||||||
|
@ -862,15 +862,14 @@ void PortGroup::processStreamIdList(int portIndex, PbRpcController *controller)
|
|||||||
controller));
|
controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
// modify port FIXME: check if there's actually any change
|
OstProto::Port portCfg = newPortContent->port_config();
|
||||||
if (newPortContent->has_port_config())
|
if (mPorts[portIndex]->modifiablePortConfig(portCfg))
|
||||||
{
|
{
|
||||||
OstProto::PortConfigList *portConfigList =
|
OstProto::PortConfigList *portConfigList =
|
||||||
new OstProto::PortConfigList;
|
new OstProto::PortConfigList;
|
||||||
OstProto::Port *port = portConfigList->add_port();
|
OstProto::Port *port = portConfigList->add_port();
|
||||||
port->CopyFrom(newPortContent->port_config());
|
port->CopyFrom(portCfg);
|
||||||
port->mutable_port_id()->set_id(portId); // overwrite
|
if (port->has_user_name())
|
||||||
if (newPortContent->port_config().has_user_name())
|
|
||||||
port->set_user_name(qPrintable(myself)); // overwrite
|
port->set_user_name(qPrintable(myself)); // overwrite
|
||||||
|
|
||||||
OstProto::Ack *ack = new OstProto::Ack;
|
OstProto::Ack *ack = new OstProto::Ack;
|
||||||
|
Loading…
Reference in New Issue
Block a user