外部调整发送队列大小,网关默认64个
This commit is contained in:
parent
b44b6c8fec
commit
e6bc135853
|
@ -215,7 +215,9 @@ TinyController::TinyController() : Controller()
|
||||||
Timeout = 200;
|
Timeout = 200;
|
||||||
|
|
||||||
_taskID = 0;
|
_taskID = 0;
|
||||||
ArrayZero(_Queue);
|
//ArrayZero(_Queue);
|
||||||
|
_Queue = NULL;
|
||||||
|
QueueLength = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
TinyController::~TinyController()
|
TinyController::~TinyController()
|
||||||
|
@ -250,6 +252,9 @@ void TinyController::Open()
|
||||||
|
|
||||||
Controller::Open();
|
Controller::Open();
|
||||||
|
|
||||||
|
// 初始化发送队列
|
||||||
|
_Queue = new MessageNode[QueueLength];
|
||||||
|
|
||||||
if(!_taskID)
|
if(!_taskID)
|
||||||
{
|
{
|
||||||
_taskID = Sys.AddTask(SendTask, this, 0, 1, "微网队列");
|
_taskID = Sys.AddTask(SendTask, this, 0, 1, "微网队列");
|
||||||
|
@ -441,7 +446,7 @@ void TinyController::AckRequest(const TinyMessage& msg)
|
||||||
{
|
{
|
||||||
if(!msg.Ack && !msg.Reply) return;
|
if(!msg.Ack && !msg.Reply) return;
|
||||||
|
|
||||||
for(int i=0; i<ArrayLength(_Queue); i++)
|
for(int i=0; i<QueueLength; i++)
|
||||||
{
|
{
|
||||||
auto& node = _Queue[i];
|
auto& node = _Queue[i];
|
||||||
if(node.Using && node.Seq == msg.Seq)
|
if(node.Using && node.Seq == msg.Seq)
|
||||||
|
@ -482,7 +487,7 @@ bool TinyController::AckResponse(const TinyMessage& msg)
|
||||||
|
|
||||||
TS("TinyController::AckResponse");
|
TS("TinyController::AckResponse");
|
||||||
|
|
||||||
for(int i=0; i<ArrayLength(_Queue); i++)
|
for(int i=0; i<QueueLength; i++)
|
||||||
{
|
{
|
||||||
auto& node = _Queue[i];
|
auto& node = _Queue[i];
|
||||||
if(node.Using && node.Seq == msg.Seq)
|
if(node.Using && node.Seq == msg.Seq)
|
||||||
|
@ -583,7 +588,7 @@ bool TinyController::Post(const TinyMessage& msg, int msTimeout)
|
||||||
|
|
||||||
// 准备消息队列
|
// 准备消息队列
|
||||||
MessageNode* node = NULL;
|
MessageNode* node = NULL;
|
||||||
for(int i=0; i<ArrayLength(_Queue); i++)
|
for(int i=0; i<QueueLength; i++)
|
||||||
{
|
{
|
||||||
if(!_Queue[i].Using)
|
if(!_Queue[i].Using)
|
||||||
{
|
{
|
||||||
|
@ -634,7 +639,7 @@ void TinyController::Loop()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(int i=0; i<ArrayLength(_Queue); i++)
|
for(int i=0; i<QueueLength; i++)
|
||||||
{
|
{
|
||||||
auto& node = _Queue[i];
|
auto& node = _Queue[i];
|
||||||
if(!node.Using) continue;
|
if(!node.Using) continue;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
class TinyController : public Controller
|
class TinyController : public Controller
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MessageNode _Queue[8]; // 消息队列。最多允许8个消息同时等待响应
|
MessageNode* _Queue; // 消息队列。允许多少个消息同时等待响应
|
||||||
|
|
||||||
RingQueue _Ring; // 环形队列
|
RingQueue _Ring; // 环形队列
|
||||||
uint _taskID; // 发送队列任务
|
uint _taskID; // 发送队列任务
|
||||||
|
@ -131,6 +131,7 @@ public:
|
||||||
byte Mode; // 接收模式。0只收自己,1接收自己和广播,2接收所有。默认0
|
byte Mode; // 接收模式。0只收自己,1接收自己和广播,2接收所有。默认0
|
||||||
ushort Interval; // 队列发送间隔,默认10ms
|
ushort Interval; // 队列发送间隔,默认10ms
|
||||||
short Timeout; // 队列发送超时,默认50ms。如果不需要超时重发,那么直接设置为-1
|
short Timeout; // 队列发送超时,默认50ms。如果不需要超时重发,那么直接设置为-1
|
||||||
|
byte QueueLength;// 队列长度,默认8
|
||||||
|
|
||||||
TinyController();
|
TinyController();
|
||||||
virtual ~TinyController();
|
virtual ~TinyController();
|
||||||
|
|
|
@ -126,9 +126,15 @@ TinyServer* Token::CreateServer(ITransport* port)
|
||||||
|
|
||||||
static TinyController ctrl;
|
static TinyController ctrl;
|
||||||
ctrl.Port = port;
|
ctrl.Port = port;
|
||||||
|
ctrl.QueueLength = 64;
|
||||||
|
|
||||||
// 只有2401需要打开重发机制
|
// 只有2401需要打开重发机制
|
||||||
if(strcmp(port->ToString(), "R24") != 0) ctrl.Timeout = -1;
|
if(strcmp(port->ToString(), "R24") != 0)
|
||||||
|
{
|
||||||
|
//ctrl.Timeout = -1;
|
||||||
|
ctrl.Interval = 200;
|
||||||
|
ctrl.Timeout = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
auto tc = TinyConfig::Current;
|
auto tc = TinyConfig::Current;
|
||||||
tc->Address = ctrl.Address;
|
tc->Address = ctrl.Address;
|
||||||
|
|
Loading…
Reference in New Issue