CN103399528B - A kind of automatic generation method of Modbus slave station simulation system - Google Patents
A kind of automatic generation method of Modbus slave station simulation system Download PDFInfo
- Publication number
- CN103399528B CN103399528B CN201310237687.6A CN201310237687A CN103399528B CN 103399528 B CN103399528 B CN 103399528B CN 201310237687 A CN201310237687 A CN 201310237687A CN 103399528 B CN103399528 B CN 103399528B
- Authority
- CN
- China
- Prior art keywords
- source code
- behavior
- generate
- slave station
- modbus
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000004088 simulation Methods 0.000 title claims abstract description 34
- 238000000034 method Methods 0.000 title claims abstract description 19
- 102100037060 Forkhead box protein D3 Human genes 0.000 claims description 21
- 101001029308 Homo sapiens Forkhead box protein D3 Proteins 0.000 claims description 21
- 238000012856 packing Methods 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 claims description 3
- 230000003139 buffering effect Effects 0.000 claims description 3
- 230000008520 organization Effects 0.000 claims description 3
- 230000001960 triggered effect Effects 0.000 claims description 3
- 238000012795 verification Methods 0.000 claims description 3
- 238000004891 communication Methods 0.000 description 7
- 238000011161 development Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000012827 research and development Methods 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention provides a kind of automatic generation method of Modbus slave station simulation system, describing many aspects from external behavior description, the description of Modbus slave station information and surface customizes generated slave station simulation system, the slave station simulation system generating has good unit affinity, can before device is produced and after producing, replace device to carry out uniformity and HIST work. The method not only can also generate source code by generating custom slave station simulation system working procedure, source code can directly apply to the exploitation of protocol apparatus itself, therefore the present invention, to reducing the complexity of protocol engineering, realizes protocol engineering automation significant.
Description
Technical field
The invention belongs to communication protocol technical field of automation, be specifically related to a kind of automatic life of Modbus slave station simulation systemOne-tenth method.
Background technology
Modbus agreement is a kind of puppy parc being applied on electronic controller. Modbus can support multiple electric interfaces,As RS232, RS485 etc., can also on various media, transmit, as twisted-pair feeder, optical fiber, wireless etc.; The frame of ModbusForm is simple, compact, easy-to-understand, and user uses easily, and manufacturer's exploitation is simple, and it has become one and has received praises from customersUniversal industrial standard.
Along with the development of industrial automation technology, industrial communication equipment (abbreviation device) quantity that meets Modbus agreement is continuousIncrease. Interconnect for various communication equipments can be realized, protocol conformance and interoperability are had higher requirement.The testing protocol consistency of this device is the essential link before device comes into operation. For to device produce before and afterwardsCan carry out easily uniformity and HIST, the simulator that research and development meet this device communication protocol is very significant,Can reduce to a great extent the development risk of device, shorten the construction cycle.
The simulator of current most Modbus agreement industry communication equipments (device) is for specific device is custom-designed accordingly,Its simulation softward is the various characteristics of analogue means preferably, but does not possess versatility, is transplanted to other workload of installing veryGreatly. Although some simulator possesses versatility to a certain degree, open customized parameter is few, well analogue meansSurface, is of limited application. Therefore exploitation can freely customize and have the simulation of the Modbus protocol apparatus of versatilityUtensil is significant.
At present, it is that test job facilitates that Modbus protocol apparatus Simulator design target mostly is replacement existing protocol device, andWorking procedure is only provided, can not provides source code support for device exploitation.
Summary of the invention
In order to overcome above-mentioned the deficiencies in the prior art, the invention provides a kind of automatic generation side of Modbus slave station simulation systemMethod, describes many aspects to generated slave station simulator from external behavior description, the description of Modbus slave station information and surfaceSystem customizes, and the slave station simulation system generating has good unit affinity, can and produce before device is producedRear replacement device carries out uniformity and HIST work. The method not only can the operation of generating custom slave station simulation systemProgram can also generate source code, and source code can directly apply to the exploitation of protocol apparatus itself, and therefore the present invention is to reducing agreementThe complexity of engineering, realizes protocol engineering automation significant.
In order to realize foregoing invention object, the present invention takes following technical scheme:
The automatic generation method that a kind of Modbus slave station simulation system is provided, said method comprising the steps of:
Step 1: definition XML format file;
Step 2: generate RS232.CS source code, SEQ.CS source code and NOSEQ.CS source code;
Step 3: generate CH_RECEIVE.CS source code, CRC_RIGHT.CS source code, CMD_EXPLAIN.CSSource code, DO_CMD.CS source code, ORG_DATA.CS source code and SEND_DATA.CS source code;
Step 4: generate ModbusSLAVE.CS source code;
Step 5: generate Modbus slave station simulation system.
In described step 1, comprise the following steps:
Step 1-1: set up the external behavior model of Modbus slave station, and the XML format file of external behavior is described in definition;
Step 1-2: set up the Modbus slave station information model of Modbus slave station, and definition description Modbus slave station informationXML format file;
Step 1-3: set up the surface model of Modbus slave station, and the XML format file of surface is described in definition.
Described step 1-1 comprises the following steps:
Step 1-1-1: set up the external behavior model of Modbus slave station, specifically comprise the following steps:
Steps A: the external behavior of Modbus slave station is divided into Receive behavior and Send behavior, described Receive behaviorBeing successfully completed is the necessary condition that Send behavior is triggered;
Step B: the delay parameter that defines the sub-behavior of described Receive behavior and each sub-behavior of Receive behavior;
The sub-behavior of described Receive behavior comprises CH_RECEIVE, CRC_RIGHT and CMD_EXPLAIN, wherein,CH_RECEIVE checks whether be subject to the data that Modbus main website sends by RS-232 interface, and CRC_RIGHT verification is sent outWhether the data CRC check coming is correct, and CMD_EXPLAIN checks whether message meets Modbus command format, and explainsThe command type of receiving;
Step C: the delay parameter of the sub-behavior of definition Send behavior and each sub-behavior of Send behavior;
The sub-behavior of described Send behavior comprises DO_CMD, ORG_DATA and SEND_DATA, wherein DO_CMDCarry out the order that Modbus main website carries out, ORG_DATA packing needs the data message sending, and SEND_DATA has sentThe response message of packing;
Step 1-1-2: according to the external behavior model of described Modbus slave station, the XML form literary composition of external behavior is described in definitionShelves; The sub-behavior delay parameter of described Receive behavior and the sub-behavior delay parameter of Send behavior all can be changed customization.
Described step 1-2 comprises the following steps:
Step 1-2-1: the Modbus slave station information model of setting up Modbus slave station;
Modbus slave station information comprises COILS, INSTATUS, HOLDREG and INREG, represents respectively coil, inputState, holding register and input register, COILS, INSTATUS, HOLDREG and INREG all use initial addressDescribe with quantity;
Step 1-2-2: the XML that describes Modbus slave station information according to the Modbus slave station information model definition of Modbus slave stationFormat file; The initial address of described COILS, INSTATUS, HOLDREG and INREG and quantity parameter all can be changedCustomization.
In described step 1-3, set up the surface model of Modbus slave station, and according to the surface mould of Modbus slave stationThe XML format file of surface is described in type definition;
Described surface comprises Modbus tributary address, Modbus response timeout time and RS232 interface configuration parameter, threePerson all can change customization.
Described step 2 comprises the following steps:
Step 2-1: generate RS232.CS source code;
Step 2-2: genesis sequence structure base class SEQ, output SEQ.CS source code;
Step 2-3: generate non-order atom behavior base class NOSEQ, output NOSEQ.CS source code.
Described step 2-1 comprises the following steps:
Step 2-1-1: generate the head source code of RS232 interface control class, comprise and quote part and RS232 interface control classStatement part;
Step 2-1-2: generate the RUN operation of RS232 interface control class, and generate RS232 serial ports class example, start RS232Interface;
Step 2-1-3: generate the STOP operation of RS232 interface control class, RS232 interface is closed;
Step 2-1-4: generate the READ operation of RS232 interface control class, make RS232 interface receive and read buffer numberAccording to;
Step 2-1-5: generate the WRITE operation of RS232 interface control class, the data of transmission are write to sending out of RS232 interfaceSend buffering area;
Step 2-1-6: generate the afterbody source code of RS232 interface control class, output RS232.CS source code.
Step 2-2 comprises the following steps:
Step 2-2-1: the head source code of genesis sequence structure base class SEQ, comprises and quote part and sequential organization base class SEQStatement part;
Step 2-2-2: the RUN operation of genesis sequence structure base class SEQ, in RUN operation, call its all child nodes,All child nodes are returned very, and RUN operation is returned very, otherwise vacation is returned in RUN operation;
Step 2-2-3: the afterbody source code of genesis sequence structure base class SEQ, output SEQ.CS source code.
Described step 2-3 comprises the following steps:
Step 2-3-1: generate the head source code of non-order atom behavior base class NOSEQ, comprise quote part and non-order formerThe statement part of sub-behavior base class NOSEQ;
Step 2-3-2: generate the abstract RUN operation of non-order atom behavior base class NOSEQ, the return type of RUN operationBe defined as bool type, not properly body of laws;
Step 2-3-3: generate the afterbody source code of non-order atom behavior base class NOSEQ, output NOSEQ.CS source code.
Described step 3 comprises the following steps:
Step 3-1: the subclass of genesis sequence structure base class SEQ, output source code; Specifically comprise:
Step 3-1-1: the subclass Receive of genesis sequence structure base class SEQ, output Receive.CS source code;
Step 3-1-2: the subclass Send of genesis sequence structure base class SEQ, output Send.CS source code;
Step 3-2: generate the subclass of non-order atom behavior base class NOSEQ, output source code; Specifically comprise:
Step 3-2-1: generate the subclasses C H_RECEIVE.CS of non-order atom behavior base class NOSEQ, outputCH_RECEIVE.CS source code;
Step 3-2-2: generate the subclasses C RC_RIGHT of non-order atom behavior base class NOSEQ, output CRC_RIGHT.CSSource code;
Step 3-2-3: generate the subclasses C MD_EXPLAIN of non-order atom behavior base class NOSEQ, outputCMD_EXPLAIN.CS source code;
Step 3-2-4: generate the subclass DO_CMD of non-order atom behavior base class NOSEQ, output DO_CMD.CS sourceCode;
Step 3-2-5: generate the subclass ORG_DATA of non-order atom behavior base class NOSEQ, output ORG_DATA.CSSource code;
Step 3-2-6: generate the subclass SEND_DATA of non-order atom behavior base class NOSEQ, output SEND_DATA.CSSource code.
In described step 4, according to the XML of the XML format file of the description Modbus slave station information of definition and description surfaceFormat file generates ModbusSLAVE.CS source code, specifically comprises the following steps:
Step 4-1: the head source code that generates ModbusSLAVE class;
Step 4-2: by COILS, INSTATUS, HOLDREG in the XML format file of description Modbus slave station informationBe mapped to the array of bool class and Int16 class with INREG, generate array source code;
Step 4-3: during by the Modbus tributary address in the XML format file of description surface, Modbus response timeoutBetween and RS232 interface configuration parameter be mapped to respectively three publicly-owned variablees of program language;
Step 4-4: generate MAIN operation, initialize and trigger the operation of Modbus slave station simulation system;
Step 4-5: generate the afterbody source code of ModbusSLAVE class, output ModbusSLAVE.CS source code.
In described step 5, merge and compile the source code of all outputs, generate Modbus slave station simulation system.
Compared with prior art, beneficial effect of the present invention is:
The present invention from external behavior describe, Modbus slave station information describe and the many aspects such as surface description to generated fromThe simulation system of standing customizes, and the slave station simulation system generating has good unit affinity, has overcome existing simulationDevice can not carry out the problem of degree of depth customization etc., can before device is produced and after producing, carry out uniformity and interoperability by replacement deviceTest job. The method not only can also generate source code by generating custom slave station simulation system working procedure, and source code canDirectly apply to the exploitation of protocol apparatus itself, overcome the problem that existing simulator can not be used for instructing the exploitation of slave station device.The present invention, to reducing the complexity of protocol engineering, realizes protocol engineering automation significant.
Brief description of the drawings
Fig. 1 is the connection diagram of Modbus slave station and Modbus main website;
Fig. 2 is the connection diagram of Modbus slave station simulation system and Modbus main website.
Detailed description of the invention
Below in conjunction with accompanying drawing, the present invention is described in further detail.
The invention provides a kind of automatic generation method of Modbus slave station simulation system, join to solve computer RS232 interfaceMatched moulds is intended the problem that software simulation Modbus communicates from station equipment and Modbus main website. Do not use Modbus simulator systemAs shown in Figure 1, Modbus main website is by RS232 interface or RS485 interface and Modbus slave station for communication modes when systemDevice communicates. Use communication modes after Modbus simulation system as shown in Figure 2, Modbus main website with by computerThe Modbus slave station simulation system that the RS232 interface of software and computer forms communicates.
Task of the present invention is to provide a kind of automatic generation method of Modbus slave station simulation system, to solve computer RS232Problem that interface coordinates simulation software simulation Modbus to communicate from station equipment and Modbus main website, and solution was in the pastMODBUS slave station unit simulator customization capability is poor and can not develop the problem that provides source code to support for installing itself. For completeBecome above-mentioned task, first the present invention provides a kind of XML document form that Modbus is described from station arrangement external behavior,The document is described from external behavior, Modbus slave station information describe and surface describe three aspects to Modbus from station arrangementBe described, user can utilize the document structure to carry out free customization to Modbus from station arrangement. Then system is according to userCustomization document generate each program class of Modbus slave station simulation program, and provide some and customization irrelevant generationThe needed common program class of Modbus slave station simulation program, finally generates all source codes of Modbus slave station simulation systemAnd compiling generation Modbus slave station dry run program is utilized computer RS232 Interface realization Modbus slave station simulation system.The method that this invention provides is significant for the automation of Modbus protocol engineering.
The automatic generation method that a kind of Modbus slave station simulation system is provided, said method comprising the steps of:
Step 1: definition XML format file;
Step 2: generate RS232.CS source code, SEQ.CS source code and NOSEQ.CS source code;
Step 3: generate CH_RECEIVE.CS source code, CRC_RIGHT.CS source code, CMD_EXPLAIN.CSSource code, DO_CMD.CS source code, ORG_DATA.CS source code and SEND_DATA.CS source code;
Step 4: generate ModbusSLAVE.CS source code;
Step 5: generate Modbus slave station simulation system.
In described step 1, comprise the following steps:
Step 1-1: set up the external behavior model of Modbus slave station, and the XML format file of external behavior is described in definition;
Step 1-2: set up the Modbus slave station information model of Modbus slave station, and definition description Modbus slave station informationXML format file, form is as follows:
Step 1-3: set up the surface model of Modbus slave station, and the XML format file of definition description surface,Form is as follows:
Described step 1-1 comprises the following steps:
Step 1-1-1: set up the external behavior model of Modbus slave station, specifically comprise the following steps:
Steps A: the external behavior of Modbus slave station is divided into Receive behavior and Send behavior, described Receive behaviorBeing successfully completed is the necessary condition that Send behavior is triggered;
Step B: the delay parameter that defines the sub-behavior of described Receive behavior and each sub-behavior of Receive behavior;
The sub-behavior of described Receive behavior comprises CH_RECEIVE, CRC_RIGHT and CMD_EXPLAIN, wherein,CH_RECEIVE checks whether be subject to the data that Modbus main website sends by RS-232 interface, and CRC_RIGHT verification is sent outWhether the data CRC check coming is correct, and CMD_EXPLAIN checks whether message meets Modbus command format, and explainsThe command type of receiving;
Step C: the delay parameter of the sub-behavior of definition Send behavior and each sub-behavior of Send behavior;
The sub-behavior of described Send behavior comprises DO_CMD, ORG_DATA and SEND_DATA, wherein DO_CMDCarry out the order that Modbus main website carries out, ORG_DATA packing needs the data message sending, and SEND_DATA has sentThe response message of packing;
Step 1-1-2: according to the external behavior model of described Modbus slave station, the XML form literary composition of external behavior is described in definitionShelves; The sub-behavior delay parameter of described Receive behavior and the sub-behavior delay parameter of Send behavior all can be changed customization.
Described step 1-2 comprises the following steps:
Step 1-2-1: the Modbus slave station information model of setting up Modbus slave station;
Modbus slave station information comprises COILS, INSTATUS, HOLDREG and INREG, represents respectively coil, inputState, holding register and input register, COILS, INSTATUS, HOLDREG and INREG all use initial addressDescribe with quantity;
Step 1-2-2: the XML that describes Modbus slave station information according to the Modbus slave station information model definition of Modbus slave stationFormat file; The initial address of described COILS, INSTATUS, HOLDREG and INREG and quantity parameter all can be changedCustomization.
In described step 1-3, set up the surface model of Modbus slave station, and according to the surface mould of Modbus slave stationThe XML format file of surface is described in type definition, and form is as follows:
1~255), the Modbus response timeout time (gets described surface comprises Modbus tributary address (span:Value scope: 10ms~2000ms) and RS232 interface configuration parameter, three all can change customization.
Described step 2 comprises the following steps:
Step 2-1: generate RS232.CS source code;
Step 2-2: genesis sequence structure base class SEQ, output SEQ.CS source code;
Step 2-3: generate non-order atom behavior base class NOSEQ, output NOSEQ.CS source code.
Described step 2-1 comprises the following steps:
Step 2-1-1: generate the head source code of RS232 interface control class, comprise and quote part and RS232 interface control classStatement part;
Step 2-1-2: generate the RUN operation of RS232 interface control class, and generate RS232 serial ports class example, start RS232Interface;
Step 2-1-3: generate the STOP operation of RS232 interface control class, RS232 interface is closed;
Step 2-1-4: generate the READ operation of RS232 interface control class, make RS232 interface receive and read buffer numberAccording to;
Step 2-1-5: generate the WRITE operation of RS232 interface control class, the data of transmission are write to sending out of RS232 interfaceSend buffering area;
Step 2-1-6: generate the afterbody source code of RS232 interface control class, output RS232.CS source code.
Step 2-2 comprises the following steps:
Step 2-2-1: the head source code of genesis sequence structure base class SEQ, comprises and quote part and sequential organization base class SEQStatement part;
Step 2-2-2: the RUN operation of genesis sequence structure base class SEQ, in RUN operation, call its all child nodes,All child nodes are returned very, and RUN operation is returned very, otherwise vacation is returned in RUN operation;
Step 2-2-3: the afterbody source code of genesis sequence structure base class SEQ, output SEQ.CS source code.
Described step 2-3 comprises the following steps:
Step 2-3-1: generate the head source code of non-order atom behavior base class NOSEQ, comprise quote part and non-order formerThe statement part of sub-behavior base class NOSEQ;
Step 2-3-2: generate the abstract RUN operation of non-order atom behavior base class NOSEQ, the return type of RUN operationBe defined as bool type, not properly body of laws;
Step 2-3-3: generate the afterbody source code of non-order atom behavior base class NOSEQ, output NOSEQ.CS source code.
Described step 3 comprises the following steps:
Step 3-1: the subclass of genesis sequence structure base class SEQ, output source code; Specifically comprise:
Step 3-1-1: the subclass Receive of genesis sequence structure base class SEQ, output Receive.CS source code;
Step 3-1-2: the subclass Send of genesis sequence structure base class SEQ, output Send.CS source code;
Step 3-2: generate the subclass of non-order atom behavior base class NOSEQ, output source code; Specifically comprise:
Step 3-2-1: generate the subclasses C H_RECEIVE.CS of non-order atom behavior base class NOSEQ, outputCH_RECEIVE.CS source code;
Step 3-2-2: generate the subclasses C RC_RIGHT of non-order atom behavior base class NOSEQ, output CRC_RIGHT.CSSource code;
Step 3-2-3: generate the subclasses C MD_EXPLAIN of non-order atom behavior base class NOSEQ, outputCMD_EXPLAIN.CS source code;
Step 3-2-4: generate the subclass DO_CMD of non-order atom behavior base class NOSEQ, output DO_CMD.CS sourceCode;
Step 3-2-5: generate the subclass ORG_DATA of non-order atom behavior base class NOSEQ, output ORG_DATA.CSSource code;
Step 3-2-6: generate the subclass SEND_DATA of non-order atom behavior base class NOSEQ, output SEND_DATA.CSSource code.
In described step 4, according to the XML of the XML format file of the description Modbus slave station information of definition and description surfaceFormat file generates ModbusSLAVE.CS source code, specifically comprises the following steps:
Step 4-1: the head source code that generates ModbusSLAVE class;
Step 4-2: by COILS, INSTATUS, HOLDREG in the XML format file of description Modbus slave station informationBe mapped to the array of bool class and Int16 class with INREG, generate array source code;
Step 4-3: during by the Modbus tributary address in the XML format file of description surface, Modbus response timeoutBetween and RS232 interface configuration parameter be mapped to respectively three publicly-owned variablees of program language;
Step 4-4: generate MAIN operation, initialize and trigger the operation of Modbus slave station simulation system;
Step 4-5: generate the afterbody source code of ModbusSLAVE class, output ModbusSLAVE.CS source code.
In described step 5, merge and compile the source code of all outputs, generate Modbus slave station simulation system.
Finally should be noted that: above embodiment is only in order to illustrate that technical scheme of the present invention is not intended to limit, although referenceAbove-described embodiment has been described in detail the present invention, and those of ordinary skill in the field are to be understood that: still can be to thisInvention detailed description of the invention modify or be equal to replacement, and do not depart from spirit and scope of the invention any amendment or etc.With replacing, it all should be encompassed in the middle of claim scope of the present invention.
Claims (1)
1. an automatic generation method for Modbus slave station simulation system, is characterized in that: said method comprising the steps of:
Step 1: definition XML format file;
Step 2: generate RS232.CS source code, SEQ.CS source code and NOSEQ.CS source code;
Step 3: generate CH_RECEIVE.CS source code, CRC_RIGHT.CS source code, CMD_EXPLAIN.CSSource code, DO_CMD.CS source code, ORG_DATA.CS source code and SEND_DATA.CS source code;
Step 4: generate ModbusSLAVE.CS source code;
Step 5: generate Modbus slave station simulation system;
In described step 1, comprise the following steps:
Step 1-1: set up the external behavior model of Modbus slave station, and the XML format file of external behavior is described in definition;
Step 1-2: set up the Modbus slave station information model of Modbus slave station, and definition description Modbus slave station informationXML format file;
Step 1-3: set up the surface model of Modbus slave station, and the XML format file of surface is described in definition;
Described step 1-1 comprises the following steps:
Step 1-1-1: set up the external behavior model of Modbus slave station, specifically comprise the following steps:
Steps A: the external behavior of Modbus slave station is divided into Receive behavior and Send behavior, described Receive behaviorBeing successfully completed is the necessary condition that Send behavior is triggered;
Step B: the delay parameter that defines the sub-behavior of described Receive behavior and each sub-behavior of Receive behavior;
The sub-behavior of described Receive behavior comprises CH_RECEIVE, CRC_RIGHT and CMD_EXPLAIN, wherein,CH_RECEIVE checks whether be subject to the data that Modbus main website sends by RS-232 interface, and CRC_RIGHT verification is sent outWhether the data CRC check coming is correct, and CMD_EXPLAIN checks whether message meets Modbus command format, and explainsThe command type of receiving;
Step C: the delay parameter of the sub-behavior of definition Send behavior and each sub-behavior of Send behavior;
The sub-behavior of described Send behavior comprises DO_CMD, ORG_DATA and SEND_DATA, wherein DO_CMDCarry out the order that Modbus main website carries out, ORG_DATA packing needs the data message sending, and SEND_DATA has sentThe response message of packing;
Step 1-1-2: according to the external behavior model of described Modbus slave station, the XML form literary composition of external behavior is described in definitionShelves; The sub-behavior delay parameter of described Receive behavior and the sub-behavior delay parameter of Send behavior all can be changed customization;
Described step 1-2 comprises the following steps:
Step 1-2-1: the Modbus slave station information model of setting up Modbus slave station;
Modbus slave station information comprises COILS, INSTATUS, HOLDREG and INREG, represents respectively coil, inputState, holding register and input register, COILS, INSTATUS, HOLDREG and INREG all use initial addressDescribe with quantity;
Step 1-2-2: the XML that describes Modbus slave station information according to the Modbus slave station information model definition of Modbus slave stationFormat file; The initial address of described COILS, INSTATUS, HOLDREG and INREG and quantity parameter all can be changedCustomization;
In described step 1-3, set up the surface model of Modbus slave station, and according to the surface mould of Modbus slave stationThe XML format file of surface is described in type definition;
Described surface comprises Modbus tributary address, Modbus response timeout time and RS232 interface configuration parameter, threePerson all can change customization;
Described step 2 comprises the following steps:
Step 2-1: generate RS232.CS source code;
Step 2-2: genesis sequence structure base class SEQ, output SEQ.CS source code;
Step 2-3: generate non-order atom behavior base class NOSEQ, output NOSEQ.CS source code;
Described step 2-1 comprises the following steps:
Step 2-1-1: generate the head source code of RS232 interface control class, comprise and quote part and RS232 interface control classStatement part;
Step 2-1-2: generate the RUN operation of RS232 interface control class, and generate RS232 serial ports class example, start RS232Interface;
Step 2-1-3: generate the STOP operation of RS232 interface control class, RS232 interface is closed;
Step 2-1-4: generate the READ operation of RS232 interface control class, make RS232 interface receive and read buffer numberAccording to;
Step 2-1-5: generate the WRITE operation of RS232 interface control class, the data of transmission are write to sending out of RS232 interfaceSend buffering area;
Step 2-1-6: generate the afterbody source code of RS232 interface control class, output RS232.CS source code;
Step 2-2 comprises the following steps:
Step 2-2-1: the head source code of genesis sequence structure base class SEQ, comprises and quote part and sequential organization base class SEQStatement part;
Step 2-2-2: the RUN operation of genesis sequence structure base class SEQ, in RUN operation, call its all child nodes,All child nodes are returned very, and RUN operation is returned very, otherwise vacation is returned in RUN operation;
Step 2-2-3: the afterbody source code of genesis sequence structure base class SEQ, output SEQ.CS source code;
Described step 2-3 comprises the following steps:
Step 2-3-1: generate the head source code of non-order atom behavior base class NOSEQ, comprise quote part and non-order formerThe statement part of sub-behavior base class NOSEQ;
Step 2-3-2: generate the abstract RUN operation of non-order atom behavior base class NOSEQ, the return type of RUN operationBe defined as bool type, not properly body of laws;
Step 2-3-3: generate the afterbody source code of non-order atom behavior base class NOSEQ, output NOSEQ.CS source code;
Described step 3 comprises the following steps:
Step 3-1: the subclass of genesis sequence structure base class SEQ, output source code; Specifically comprise:
Step 3-1-1: the subclass Receive of genesis sequence structure base class SEQ, output Receive.CS source code;
Step 3-1-2: the subclass Send of genesis sequence structure base class SEQ, output Send.CS source code;
Step 3-2: generate the subclass of non-order atom behavior base class NOSEQ, output source code; Specifically comprise:
Step 3-2-1: generate the subclasses C H_RECEIVE.CS of non-order atom behavior base class NOSEQ, outputCH_RECEIVE.CS source code;
Step 3-2-2: generate the subclasses C RC_RIGHT of non-order atom behavior base class NOSEQ, output CRC_RIGHT.CSSource code;
Step 3-2-3: generate the subclasses C MD_EXPLAIN of non-order atom behavior base class NOSEQ, outputCMD_EXPLAIN.CS source code;
Step 3-2-4: generate the subclass DO_CMD of non-order atom behavior base class NOSEQ, output DO_CMD.CS sourceCode;
Step 3-2-5: generate the subclass ORG_DATA of non-order atom behavior base class NOSEQ, output ORG_DATA.CSSource code;
Step 3-2-6: generate the subclass SEND_DATA of non-order atom behavior base class NOSEQ, output SEND_DATA.CSSource code;
In described step 4, according to the XML format file of the description Modbus slave station information of definition with describe surfaceXML format file generates ModbusSLAVE.CS source code, specifically comprises the following steps:
Step 4-1: the head source code that generates ModbusSLAVE class;
Step 4-2: by COILS, INSTATUS, HOLDREG in the XML format file of description Modbus slave station informationBe mapped to the array of bool class and Int16 class with INREG, generate array source code;
Step 4-3: during by the Modbus tributary address in the XML format file of description surface, Modbus response timeoutBetween and RS232 interface configuration parameter be mapped to respectively three publicly-owned variablees of program language;
Step 4-4: generate MAIN operation, initialize and trigger the operation of Modbus slave station simulation system;
Step 4-5: generate the afterbody source code of ModbusSLAVE class, output ModbusSLAVE.CS source code;
In described step 5, merge and compile the source code of all outputs, generate Modbus slave station simulation system.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310237687.6A CN103399528B (en) | 2013-03-06 | 2013-06-14 | A kind of automatic generation method of Modbus slave station simulation system |
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310071319 | 2013-03-06 | ||
CN2013100713199 | 2013-03-06 | ||
CN201310071319.9 | 2013-03-06 | ||
CN201310237687.6A CN103399528B (en) | 2013-03-06 | 2013-06-14 | A kind of automatic generation method of Modbus slave station simulation system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103399528A CN103399528A (en) | 2013-11-20 |
CN103399528B true CN103399528B (en) | 2016-05-25 |
Family
ID=49563171
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310237687.6A Active CN103399528B (en) | 2013-03-06 | 2013-06-14 | A kind of automatic generation method of Modbus slave station simulation system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103399528B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105025056A (en) * | 2014-04-25 | 2015-11-04 | 上海迪爱斯通信设备有限公司 | Internet of Things information collection and monitoring system design method |
CN103984555B (en) * | 2014-05-29 | 2017-03-15 | 四川航天系统工程研究所 | A kind of tree table is combined and drives Windows/Linux platform communications protocol source profiles methods |
CN106506187A (en) * | 2015-09-08 | 2017-03-15 | 中兴通讯股份有限公司 | The communication means of equipment simulator and system |
WO2017166267A1 (en) * | 2016-04-01 | 2017-10-05 | Intel Corporation | Consistent generation and customization of simulation firmware and platform in computing environments |
CN109460231B (en) * | 2018-09-25 | 2022-02-22 | 北京通广龙电子科技有限公司 | Upper computer software implementation method based on XML |
CN112311808B (en) * | 2020-11-11 | 2023-03-21 | 上海电器科学研究所(集团)有限公司 | Method for automatically mapping Modbus protocol data to OPCUA address space |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101398755A (en) * | 2008-08-22 | 2009-04-01 | 满延平 | Software auto generating method based on template |
CN101436128A (en) * | 2007-11-16 | 2009-05-20 | 北京邮电大学 | Software test case automatic generating method and system |
CN101464799A (en) * | 2009-01-16 | 2009-06-24 | 天津大学 | MPI parallel programming system based on visual modeling and automatic skeleton code generation method |
CN101776993A (en) * | 2009-01-09 | 2010-07-14 | 鸿富锦精密工业(深圳)有限公司 | System and method automatically generating software interactive interface |
CN102176200A (en) * | 2009-09-25 | 2011-09-07 | 南京航空航天大学 | Software test case automatic generating method |
US8117534B1 (en) * | 2004-06-09 | 2012-02-14 | Oracle America, Inc. | Context translation |
-
2013
- 2013-06-14 CN CN201310237687.6A patent/CN103399528B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8117534B1 (en) * | 2004-06-09 | 2012-02-14 | Oracle America, Inc. | Context translation |
CN101436128A (en) * | 2007-11-16 | 2009-05-20 | 北京邮电大学 | Software test case automatic generating method and system |
CN101398755A (en) * | 2008-08-22 | 2009-04-01 | 满延平 | Software auto generating method based on template |
CN101776993A (en) * | 2009-01-09 | 2010-07-14 | 鸿富锦精密工业(深圳)有限公司 | System and method automatically generating software interactive interface |
CN101464799A (en) * | 2009-01-16 | 2009-06-24 | 天津大学 | MPI parallel programming system based on visual modeling and automatic skeleton code generation method |
CN102176200A (en) * | 2009-09-25 | 2011-09-07 | 南京航空航天大学 | Software test case automatic generating method |
Also Published As
Publication number | Publication date |
---|---|
CN103399528A (en) | 2013-11-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103399528B (en) | A kind of automatic generation method of Modbus slave station simulation system | |
WO2009021974A2 (en) | Real-time industrial ethernet ethercat communication control | |
CN104635682B (en) | A kind of embedded MPS investigating method of Internet of Things and network system device | |
CN101655699A (en) | Systems and methods for simulating plant operations | |
CN102117571A (en) | Online teaching processing system for glue dispensing machine | |
CN103538069A (en) | Robot control method, control device and control system | |
CN102722126A (en) | Four-roll plate bending machine control system based on advanced RISC machine (ARM) and Wince | |
CN104698950A (en) | Peripheral device control method, microcontroller, upper computer and system | |
CN105807628A (en) | Robot flexible controller for complex CPS (Cyber Physical System) and implementation method thereof | |
CN102495552A (en) | Real-time simulation system oriented to space-borne electronic system | |
CN101551827B (en) | Test method and device capable of switching multi-simulation accuracy | |
CN202694145U (en) | Test system of main control board | |
CN101630343A (en) | Simulation method and simulation system | |
CN103605526A (en) | Template componentized code generating method based on chain-of-responsibility pattern | |
CN105846859A (en) | Bluetooth slave device function implementation system and method of embedded operating system | |
CN105487403A (en) | Establishment of motion control system based on CAN and simulation modeling method | |
Campanelli et al. | An architecture to integrate IEC 61131-3 systems in an IEC 61499 distributed solution | |
CN101666855A (en) | Universal test system and method of integrated circuit | |
CN103576667B (en) | Method, device and system for testing main control board | |
CN113031461B (en) | Semi-physical simulation system and method for ultra-precise motion platform | |
CN113687814A (en) | Automation realization method of model framework and interface file based on AUTOSAR (automotive open system architecture) | |
CN109634584A (en) | A kind of driving encapsulation and communication mechanism based on code building | |
CN108550296A (en) | Multi-brand Robot Virtual teaching machine system | |
CN106354966B (en) | The method of the conversion of chip id E project file and rapid configuration artificial debugging environment | |
Qi et al. | ECHONET lite framework based on embedded component systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |