The content of the invention
It is an object of the present invention to provide a kind of control method of smart jack, solves above technical problem.
The present invention also aims to, there is provided a kind of control device of smart jack, solve above technical problem.
Technical problem solved by the invention can be realized using following technical scheme:
The present invention provides a kind of control method of smart jack, wherein, comprise the following steps:
Step 1, smart jack determines whether that client sends an external command to the smart jack;
Step 2, the smart jack judges whether the external command is subjected to, if not, the smart jack produces
One status information, the client resend the external command after postponing setting time according to the status information, repeat
Step 1;
Step 3, the external command is inserted into a command buffer alignment;
Step 4, the order according to the command buffer alignment performs the order in the command buffer alignment successively.
The control method of the smart jack of the present invention, the step 2 comprise the following steps that:
Step 21:The smart jack judges whether the command buffer alignment is full, if full, performs step 26;
Step 22, each corresponding timeout value of order waited in line in the command buffer alignment is obtained;
Step 23, all orders in the command buffer alignment are calculated to be finished stand-by period of needs;
Step 24, the stand-by period timeout value corresponding with the external command that active client is sent is calculated
Difference;
Step 25, judge whether the difference is more than zero, if not, performing step 3;
Step 26, the smart jack returns to one to the client and refers to delay time value, and the client is according to institute
State and resend the external command, repeat step 1 with reference to after delay time value delay setting time.
The present invention also provides a kind of control device of smart jack, for implementing the control method of above-mentioned smart jack,
Including,
Interface module, it is connected with the client, for receiving the external command;
Memory module, stores the command buffer alignment, and the command buffer alignment includes the order waited in line successively;
Judge module, judge whether the external command is subjected to according to imposing a condition;
Order add module, to add the external command to the command buffer alignment;
Execution module, sequentially perform the order in the command buffer alignment.
The smart jack control device of the present invention, the memory module also store the corresponding timeout value of each order.
The smart jack control device of the present invention, the judge module includes one and overflows judge module, described to judge
Whether command buffer alignment is full.
The smart jack control device of the present invention, the judge module includes the first computing module, to calculate current life
All orders waited in line in buffering queue are made to be finished stand-by period of needs.
The smart jack control device of the present invention, the judge module also includes the second computing module, to will be described etc.
Treat that time and the timeout value of the external command take difference.
The smart jack control device of the present invention, the interface module connect a local area network or cloud server, connect
Receive the external command that the client being connected with the local area network or the cloud server is sent.
Beneficial effect:Due to using above technical scheme, the present invention performs remote command, a side by consulting with client
Face prevents socket from causing buffer overflow due to ordering excessive;On the other hand mitigate and perform what is excessively ordered in the socket short time
Pressure;Due to the status information that client can return according to socket, order is resend after reasonably postponing setting time, from
And improve Consumer's Experience;It is smart jack when performing from the remote command of client, there is provided more efficient solution sees,
And realize relatively easy.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art obtained on the premise of creative work is not made it is all its
His embodiment, belongs to the scope of protection of the invention.
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the present invention can phase
Mutually combination.
The invention will be further described with specific embodiment below in conjunction with the accompanying drawings, but not as limiting to the invention.
Reference picture 1, the control method of smart jack, wherein, comprise the following steps:
Step 1, smart jack determines whether that client sends an external command to smart jack;
Step 2, smart jack judges whether external command is subjected to, if not, smart jack produces a status information, visitor
Family end resends external command after postponing setting time according to status information;
Step 3, external command is inserted into a command buffer alignment;
Step 4, the order according to command buffer alignment performs the order in command buffer alignment successively.
In order to ensure the read-write uniformity of data, smart jack is typically serially to perform these orders one by one, then rearward
Order before the client of transmission order just needs to wait until is finished, and could obtain result, and the stand-by period is possible to longer,
So as to influence the Consumer's Experience of client.The hardware processing capability of smart jack in itself is limited after all, if this raising hardware
Performance, manufacturing cost will be increased.The control method of the smart jack of the present invention is first assessed after long-range external command is received
The current processing capabilities of system, if resource allows, just receive external command and be placed into command buffer alignment to wait in line to perform;
If it find that system is busy or resource soon reaches critical point, the status information of socket is returned to inform client, state
Information can be some reference values, for example suggest when client resends order.
The control method of the smart jack of the present invention, reference picture 2, one kind of step 2 comprise the following steps that:
Step 21:Smart jack judges whether command buffer alignment is full, if full, performs step 26;
Step 22, each corresponding timeout value of order waited in line in command buffer alignment is obtained;
Step 23, all orders in calculation command buffering queue are finished the stand-by period of needs;
Step 24, the difference of the stand-by period timeout value corresponding with the external command that active client is sent is calculated;
Step 25, judge whether difference is more than zero, if not, performing step 3;
Step 26, smart jack returns to one to client and refers to delay time value, and client foundation refers to delay time value
External command, repeat step 1 are resend after delay setting time.
Smart jack needs the timeout value (command_timeout) of every order of predefined, and specially sets up one
Module carries out system resource assessment.When smart jack receives the external command of client, first the external command is carried out
Assess, if external command can receive, be put into queue waiting and perform;Otherwise return a time delay, and by this
Time delay is passed back to client, and a reference value of the external command is resend as delay.
The key point of the present invention is how whether accurate evaluation goes out order can be by timely processing.On the one hand, it is more accurate to assess,
Socket is higher with the coordinating efficiency of client;But then, assessment can also consume jack system resource, and technology in itself
Difficulty also can accordingly increase.So balance will be obtained between the two in accuracy and performance by assessing.The implementation process of step 2 can be with
Flexibly selection other modes, it is therefore intended that prevent smart jack is before order is from timely processing, can be by the shape of smart jack
State information returns to client, and issues the reference value of a time delay, for example is resend after suggesting client delay 2 seconds outer
Portion's order.
Step 2 can be realized by following computer program, and pseudo-code is given below:
The present invention also provides a kind of control device of smart jack, reference picture 3, for implementing the control of above-mentioned smart jack
Method processed, including,
Interface module 1, is connected with client, for receiving external command;
Memory module 2, stores command buffer alignment, and command buffer alignment includes the order waited in line successively;
Judge module 3, judges whether external command is subjected to;
Order add module 4, to add external command to command buffer alignment;
Execution module 5, order perform the order in command buffer alignment.
The smart jack control device of the present invention, memory module 2 also store the corresponding timeout value of each order.
The smart jack control device of the present invention, judge module 3 can include one and overflow judge module, described to judge
Whether command buffer alignment is full.
The smart jack control device of the present invention, judge module 3 can also include the first computing module, current to calculate
All orders waited in line in command buffer alignment are finished stand-by period of needs;
The smart jack control device of the present invention, judge module 3 can with the second computing module, to by the stand-by period with
External command timeout value takes difference.
The smart jack control device of the present invention, interface module 1 connect a local area network or cloud server, receive with
The external command that local area network or the client of cloud server connection are sent.
The present invention realize it is relatively easy, by with client consult perform remote command, on the one hand prevent socket due to life
Order is excessive and causes buffer overflow;On the other hand the pressure for performing in the socket short time and excessively ordering is mitigated;Due to client
The status information that can be returned according to socket, reasonably postpones or retransmits order, so as to improve Consumer's Experience;Exist for smart jack
Perform from the remote command of client when, there is provided more efficient solution.
Preferred embodiments of the present invention are the foregoing is only, not thereby limit embodiments of the present invention and protection model
Enclose, to those skilled in the art, should can appreciate that all with made by description of the invention and diagramatic content
Scheme obtained by equivalent substitution and obvious change, should be included in protection scope of the present invention.