Controller, control system and control method
By introducing an access processing unit into the PLC controller to extract and resend qualified items in the error list of database access requests, the problem of database connection error recovery is solved and the stability and data integrity of the system are improved.
Patent Information
- Application Number
- CN202080046727.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-03
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-03-03
AI Technical Summary
In controllers such as PLC, errors are prone to occur when accessing the database, and it is difficult to flexibly recover with existing technology, thus affecting system stability and data integrity.
A controller is designed, which includes a communication interface, a command execution unit and an access processing unit. The access processing unit extracts qualified access requests from the error list and resends them through the communication interface to ensure that the system can flexibly restore the database connection.
Extracting and resending access requests through user-set conditions can effectively prevent inappropriate access requests, improve the recovery ability of database connections, and avoid repeated resending and error management.
Smart Images

Figure CN114072738B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a controller for controlling a control object, a control system including the controller, and a control method executed by the controller. Background Art
[0002] Many control objects such as machines and equipment used in production sites are controlled by controllers such as programmable logic controllers (hereinafter also referred to as "PLCs"), and with the advancement of information processing technology in recent years, such controllers have become more multifunctional.
[0003] For example, Japanese Patent Application Publication No. 2012-108642 (Patent Document 1) discloses a data collection system that stores predetermined data collected by a control device such as a programmable controller (PLC) in a database. The programmable controller includes an SQL sending unit that sends an SQL processing group including a plurality of SQL statements for accessing the database to the database via a communication path.
[0004] Prior art literature
[0005] Patent Literature
[0006] Patent Document 1: Japanese Patent Application Publication No. 2012-108642 Summary of the invention
[0007] Problems to be solved by the invention
[0008] The controller as described above issues an access request for writing data into the database device or deleting data on the database device. As such an access request, typically, an SQL statement used in a relational database management system is known.
[0009] In controllers such as PLCs, such access requests are typically generated and sent by executing a user program designed according to the control object. In such a structure that uses a user program to issue an access request, in consideration of the reusability of the program, most of them are designed to use variable variables (parameters) to specify the object range of data writing or deletion.
[0010] Errors may occur in accessing (connecting) the database. It is desirable to be able to recover flexibly when recovering from errors.
[0011] An object of the present disclosure is to provide a controller capable of flexibly recovering from an error in a database connection, a control system including the controller, and a control method executed by the controller.
[0012] Means for solving problems
[0013] A controller of an example of the present disclosure controls a control object, wherein the controller includes: a communication interface for accessing a database device; a command execution unit for executing a user program including an access command for accessing the database device and associated with the control of the control object; and an access processing unit for generating an access request in response to the access command being executed by the command execution unit, and causing the communication interface to send the access request. The access processing unit extracts an access request that meets a specified condition from an error list that records access requests when access to the database device fails, and causes the communication interface to resend the extracted access request.
[0014] According to this configuration, the access processing unit can extract only access requests that meet the retransmission condition from the error list and retransmit them to the database device. Therefore, it is possible to provide a controller that can flexibly recover from database connection errors.
[0015] The access request may typically be a SQL statement used in a relational database management system.
[0016] Preferably, the command execution unit extracts the access request satisfying the predetermined condition based on a user input related to setting of the predetermined condition, and the command access processing unit extracts the access request satisfying the predetermined condition.
[0017] According to this configuration, the user can set the extraction condition and select the access request that satisfies the extraction condition. Therefore, it is possible to provide a controller that can properly recover from a database connection error.
[0018] Preferably, the command execution unit executes a user program for displaying information representing the access request extracted from the error list by the access processing unit, and in accordance with user input related to selection of the access request, instructs the access processing unit to cause the communication interface to resend the access request selected by the user.
[0019] According to this configuration, the user can confirm the access request to be selected from a plurality of access requests satisfying the extraction condition.
[0020] Preferably, when the communication interface succeeds in retransmitting the access request, the access processing unit deletes the corresponding access request from the error list.
[0021] According to this configuration, once retransmission of an access request succeeds, repeated retransmission of the access request can be prevented.
[0022] Preferably, when the communication interface fails in retransmission of the access request, the access processing unit generates information on the failure of the retransmission.
[0023] According to this configuration, it is possible to manage the results related to the retransmission of the access request.
[0024] A control system according to an example of the present disclosure includes: a controller as described in any one of the above; and a database device that receives an access request from the controller.
[0025] According to this configuration, it is possible to provide a control system that can flexibly recover from a database connection error.
[0026] A control method of an example disclosed herein is a control method for a controller that controls a control object, which comprises the following steps: the controller executes an access command for accessing a database device; the controller generates an access request; the controller sends the access request to the database device; the controller saves the access request when the access to the database device fails into an error list; the controller extracts the access request that meets the specified conditions from the error list; and the controller resends the extracted access request to the database device.
[0027] According to this configuration, it is possible to provide a control method that can flexibly recover from a database connection error.
[0028] Effects of the Invention
[0029] According to the present invention, it is possible to prevent an inappropriate access request from being generated and sent due to execution of a user program. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a diagram for explaining the functional overview of the PLC according to the present embodiment.
[0031] Figure 2 It is a schematic diagram showing a system configuration of a control system 1 including a PLC according to the present embodiment.
[0032] Figure 3 It is a schematic diagram showing the hardware configuration of the main part of the PLC according to the present embodiment.
[0033] Figure 4 It is a schematic diagram showing the software structure of the PLC according to the present embodiment.
[0034] Figure 5 It is a schematic diagram showing the hardware configuration of a support device used in connection with the PLC of the present embodiment.
[0035] Figure 6 This is a schematic diagram for explaining an implementation example of an access request provided by the PLC of this embodiment.
[0036] Figure 7 This is a schematic diagram showing the retransmission of the SQL statement according to the first embodiment of the present invention.
[0037] Figure 8 This is a diagram showing an example of a first function block included in a user program.
[0038] Fig. 9 is an example input to Figure 8 A diagram of the information of the functional blocks shown.
[0039] Fig.10 This is a sequence diagram showing the SQL statement retransmission processing steps of the first embodiment of the present invention.
[0040] Fig.11 This is a schematic diagram showing the retransmission of the SQL statement according to the second embodiment of the present invention.
[0041] Fig.12 This is a diagram showing an example of a second function block included in a user program.
[0042] Fig.13 This is a diagram showing an example of a third function block included in a user program.
[0043] Fig.14 This is a diagram showing an example of a fourth function block included in the user program 186 .
[0044] Fig.15 This is a diagram showing an example of a screen of a tool for accepting SQL statement selection from a user.
[0045] Fig.16 This is a sequence diagram showing the SQL statement retransmission processing steps of the second embodiment of the present invention.
[0046] Fig.17 This is a sequence diagram showing the process for preventing erroneous retransmission of SQL statements according to the present embodiment. DETAILED DESCRIPTION
[0047] The embodiments of the present invention will be described in detail with reference to the accompanying drawings. In addition, the same or corresponding parts in the drawings are denoted by the same reference numerals and their description will not be repeated.
[0048] <A. Summary>
[0049] First, the controller of the present embodiment is described in terms of its functions. In the following description, a programmable controller (PLC) for controlling a control object such as a machine or equipment is described as a specific example of a controller. However, the controller of the present embodiment is not limited to a PLC, and can be applied to various controllers and information processing devices.
[0050] Figure 1 1 is a diagram for explaining the functional overview of the PLC 100 according to the present embodiment. Figure 1 The PLC 100 is configured to be able to transmit and receive data with the database device 400. That is, the PLC 100 and the database device 400 are configured to be able to exchange data with each other via a network 112 such as Ethernet (registered trademark).
[0051] More specifically, the PLC 100 includes a command execution unit 2, an access processing unit 4, and a communication interface 6. Some or all of these components may be implemented by a processor executing a program described later, or may be implemented by dedicated hardware. Figure 1 The components shown are schematically represented from a functional point of view, and there is no limitation on the implementation method of each component.
[0052] The command execution unit 2 executes a user program 186 related to the control of a control object such as a machine or device. Basically, the command execution unit 2 executes the user program 186 periodically or event-wise. That is, the PLC 100 is configured to control the control object by repeatedly executing the user program 186. The user program 186 is typically created by a support device 300 described later and sent to the PLC 100. The user program 186 executed by the command execution unit 2 sometimes also includes a command (access command) for accessing the database device 400. In this case, by executing the access command, an internal instruction requesting access to the database device 400 is issued to the access processing unit 4.
[0053] When receiving the internal command for requesting access to the database device 400 from the command execution unit 2, the access processing unit 4 issues the internal command required for issuing the access request to the database device 400 to the communication interface 6. That is, the access processing unit 4 causes the communication interface 6 to send the access request in response to the access command for accessing the database device 400 included in the user program 186 executed by the command execution unit 2. That is, the system program 188 includes a command for the following processing: when the access command is executed in conjunction with the execution of the user program 186, a process for generating an access request for the database device 400 according to information specifying an access range; and a process for executing the access request via the communication interface 6.
[0054] The communication interface 6 generates a command (request) required for communicating with the database device 400 according to an internal command from the access processing unit 4, and transmits it via the network 112. The communication interface 6 also receives data (execution results) transmitted from the database device 400 and the like via the network 112.
[0055] Figure 1 The processing in the PLC 100 shown until an access request to the database device is sent is: (1) periodic / event-based execution of the user program 186 by the command execution unit 2; (2) issuance of an internal instruction for issuing an access request by the access processing unit 4 in response to the execution of the access command contained in the user program 186; and (3) sending of the access request by the communication interface 6 in response to the issuance of the internal instruction from the access processing unit 4.
[0056] Hereinafter, the PLC 100 of the present embodiment and the functions installed therein will be described in more detail.
[0057] <B. System structure>
[0058] Figure 2 1 is a schematic diagram showing a system configuration of a control system 1 including a PLC 100 according to the present embodiment. Figure 2 The control system 1 includes a PLC 100, a support device 300 connected to the PLC 100, and a database device 400 that receives access from the PLC 100. The PLC 100 executes a user program periodically or in an event. By executing the access command included in the user program, the database device 400 is processed.
[0059] The support device 300 is a typical example of an information processing device that generates a user program executed by the PLC 100. The support device 300 is connected to the PLC 100 via the connection cable 114, and provides functions such as setting various parameters, programming, monitoring, and debugging with the PLC 100.
[0060] The PLC 100 includes a CPU unit 104 that executes control calculations and one or more IO (Input / Output) units 106. These units are configured to be able to exchange data with each other via a PLC system bus 108. A power supply unit 102 supplies power of an appropriate voltage to these units.
[0061] In the control system 1, the PLC 100 exchanges data with various field devices via the IO unit 106 (connected via the PLC system bus 108) and / or via the field bus 110. These field devices include actuators for performing certain processes on the controlled object, sensors for obtaining various information from the controlled object, etc. Figure 2 In the PLC 100, as an example of such a field device, a detection switch 10, a relay 20, and a servo motor driver 30 for driving a motor 32 are included. A remote IO terminal 200 is also connected to the PLC 100 via the field bus 110. The remote IO terminal 200 basically performs processing related to normal input and output processing in the same manner as the IO unit 106. More specifically, the remote IO terminal 200 includes a communication coupler 202 for performing processing related to data transmission using the field bus 110, and one or more IO units 204. These units are configured to be able to exchange data with each other via the remote IO terminal bus 208.
[0062] <C. Structure of PLC 100>
[0063] Next, the configuration of the PLC 100 according to the present embodiment will be described. Figure 3 It is a schematic diagram showing the hardware configuration of the main part of PLC100 which represents this embodiment. Figure 4 It is a schematic diagram showing the software configuration of the PLC 100 according to the present embodiment.
[0064] Reference Figure 3 , the hardware structure of the CPU unit 104 of the PLC 100 is described. The CPU unit 104 includes a processor 120, a chipset 122, a system clock 124, a main memory 126, a non-volatile memory 128, a communication connector 130, a PLC system bus controller 140, a field bus controller 150, an upper communication controller 160, and a memory card interface 170. The chipset 122 is connected to other components via various buses.
[0065] The processor 120 and the chipset 122 are typically constructed based on a general computer architecture. That is, the processor 120 interprets and executes the command code supplied sequentially from the chipset 122 according to the internal clock. For ease of explanation, only a single processor 120 is illustrated, but it is not limited to this, and any structure can be adopted. For example, a structure including multiple processors including a single core, a structure including multiple single processors, a structure including multiple processors including multiple cores, etc. can also be adopted. That is, the controller of this embodiment can also be implemented by executing a program by one or more processors.
[0066] The chipset 122 exchanges internal data with various connected components and generates command codes required by the processor 120. The system clock 124 generates a system clock with a predetermined period and supplies it to the processor 120. The chipset 122 has a function of caching data obtained as a result of execution of arithmetic processing in the processor 120.
[0067] The CPU unit 104 has a main memory 126 and a nonvolatile memory 128 as storage means. The main memory 126 is a volatile storage area that stores various programs to be executed by the processor 120 and is also used as a job memory when executing various programs. The nonvolatile memory 128 stores an OS (Operating System), a system program, a user program, data definition information, log information, etc. in a nonvolatile manner.
[0068] The communication connector 130 is an interface for connecting the support device 300 to the CPU unit 104 via the connection cable 114. Typically, an executable program or the like transmitted from the support device 300 is taken into the CPU unit 104 via the communication connector 130. As an example, the communication connector 130 is a USB connector, but the communication standard and the type of the communication connector 130 corresponding to the standard are not particularly limited.
[0069] The CPU unit 104 includes a PLC system bus controller 140, a field bus controller 150, and a host communication controller 160 as communication means. These communication circuits transmit and receive data.
[0070] The PLC system bus controller 140 controls data exchange via the PLC system bus 108. More specifically, the PLC system bus controller 140 includes a buffer memory 142, a PLC system bus control circuit 144, and a DMA (Dynamic Memory Access) control circuit 146. The PLC system bus controller 140 is connected to the PLC system bus 108 via a PLC system bus connector 148.
[0071] The field bus controller 150 includes a buffer memory 152, a field bus control circuit 154, and a DMA control circuit 156. The field bus controller 150 is connected to the field bus 110 via a field bus connector 158. The host communication controller 160 includes a buffer memory 162, a host communication control circuit 164, and a DMA control circuit 166. The host communication controller 160 is connected to the network 112 via a host communication connector 168.
[0072] The memory card interface 170 connects a memory card 172 detachable from the CPU unit 104 to the processor 120 .
[0073] Next, refer to Figure 4 , the software structure for realizing various functions provided by the PLC 100 of this embodiment will be described. The command codes included in these software are read out at appropriate timing and executed by the processor 120 of the CPU unit 104.
[0074] Reference Figure 4 The software executed by the CPU unit 104 includes three levels: an OS 180 , a system program 188 , and a user program 186 .
[0075] The OS 180 provides a basic execution environment for executing a system program 188 and a user program 186 by the processor 120 .
[0076] The system program 188 is a software group for providing basic functions as the PLC 100. Specifically, the system program 188 includes a sequence command library 190, a DB (database) access processing library 191, a monitoring processing library 192, an input / output processing library 193, a tool interface processing program 194, and a scheduler 195.
[0077] On the other hand, the user program 186 is a program arbitrarily created according to the control purpose for the control object. In other words, the user program 186 is arbitrarily designed according to the production line (process) or the like of the object to be controlled using the control system 1.
[0078] The user program 186 cooperates with the sequence command library 190 to achieve the user's control purpose. That is, the user program 186 implements the programmed actions by using the commands, functions, functional modules, etc. provided by the sequence command library 190. Therefore, the user program 186 and the sequence command library 190 are sometimes collectively referred to as "control programs".
[0079] These programs, libraries, and the like are stored in the nonvolatile memory 128. That is, the nonvolatile memory 128 corresponds to a memory that stores the system program 188 and the user program 186.
[0080] The data definition information 182 includes a definition for processing the referenced data (input data, output data, internal data) as a unique variable when executing the user program 186, etc. In the operation log 184, when a predetermined event occurs with the execution of the system program 188 and the user program 186, the information of the event that occurred is associated with the time information and stored. That is, in the operation log 184, various information accompanying the execution of the system program 188 and / or the user program 186 is stored as a log (history information).
[0081] Each program is described below in more detail.
[0082] The sequence command library 190 includes a command code group for calling the entity of the sequence command specified in the user program 186 and implementing the content of the command along with the execution of the user program 186.
[0083] The DB access processing library 191 includes a command code group for realizing processing required for accessing the database device 400 in conjunction with the execution of the user program 186. The DB access processing library 191 includes execution codes corresponding to commands that can be specified in the user program 186.
[0084] The monitoring processing library 192 is a program for realizing the access request restriction function of this embodiment. The details of the function provided by the monitoring processing library 192 will be described later.
[0085] The input / output processing library 193 is a program for managing the acquisition of input data and the transmission of output data with the IO unit 106 and various field devices.
[0086] The tool interface processing program 194 provides an interface for exchanging data with the support device 300 .
[0087] The scheduler 195 generates threads and processes for executing the control program according to a predetermined priority, a system timer value, and the like.
[0088] As described above, the user program 186 is created according to the user's control purpose (for example, a production line or process as an object). The user program 186 is typically in the form of an object program that can be executed by the processor 120 of the CPU unit 104. The user program 186 is generated by compiling a source program described in a ladder diagram form or a function block form in the support device 300, etc. Then, the generated user program in the form of an object program is transmitted from the support device 300 to the CPU unit 104 and stored in the non-volatile memory 128, etc.
[0089] In the above description, the following embodiment is exemplified: when the processor 120 executes the user program 186 stored in the memory, the system program is read out and the programs included in the DB access processing library 191 and the monitoring processing library 192 in the system program are executed. However, as long as the configuration includes the following programs described by the user program 186: a program that receives and sends access requests to the database device in response to the execution of an access command (as an example, a database connection service); and a program that monitors information that specifies the range of access to the database when the command is executed (as an example, a monitoring service), it is not limited to the above embodiment.
[0090] <D. Configuration of the support device 300 >
[0091] Next, the support device 300 of this embodiment is described. The support device 300 is used to assist the use of the CPU unit 104 of the PLC 100, and provides functions such as setting of various parameters, programming, monitoring, and debugging between the PLC 100.
[0092] Figure 5 1 is a schematic diagram showing a hardware configuration of a support device 300 used in connection with the PLC 100 of the present embodiment. The support device 300 is typically configured by a general-purpose computer.
[0093] Reference Figure 5 The support device 300 includes: a CPU 302 that executes various programs including an OS; a ROM (Read Only Memory) 304 that stores BIOS and various data; a RAM 306 that provides a work area for storing data required for the CPU 302 to execute programs; and a hard disk (HDD) 308 that stores programs executed by the CPU 302 in a non-volatile manner. More specifically, the hard disk 308 stores a support program 330 for realizing the functions provided by the support device 300.
[0094] The support device 300 further includes a keyboard 310 and a mouse 312 for accepting operations from a user, and a monitor 314 for presenting information to the user. The support device 300 also includes a communication interface (IF) 318 for communicating with the PLC 100 (CPU unit 104) and the like.
[0095] The support program 330 executed by the support device 300 is typically stored in an optical disk 332 as an example of a computer-readable recording medium and circulated. The support program stored in the optical disk 332 is read by the optical disk reading device 316 and stored in the hard disk 308. Alternatively, the program may be downloaded from a host computer or the like via a network.
[0096] <E. Configuration of Database Device 400 >
[0097] Next, the database device 400 of this embodiment is described. As the database device 400, a known structure for providing a database can be adopted. As such a database, any structure such as a relational data type and an object data type can be adopted. The database device 400 is constructed according to a general computer architecture, so its detailed description is not repeated here.
[0098] The database device 400 receives a connection request or an access request (SQL statement in the relational data type) from the PLC 100, performs necessary processing, and responds to the PLC 100 with the processing result and the like. Typically, through the SQL statement, processing such as writing the specified data to the specified location or range, reading the data stored in the specified location or range, and deleting the data stored in the specified location or range is performed. In one embodiment described below, the database device 400 is a relational data type, and the access request is an SQL statement.
[0099] In the above description, the database device 400 is exemplified as a device for providing a database, but the structure is not limited to this structure, and various structures can be adopted. That is, as long as the structure has the basic functions of the database, such as the function of retaining data, the function of processing according to access requests, and the function of responding to the client with the processing results, any structure can be adopted. Therefore, a structure in which a single device has other functions in addition to the database function, a structure in which multiple devices cooperate to provide a single database function, etc. can be adopted.
[0100] <F. Database access function>
[0101] Next, an implementation example of the database access function provided by the PLC 100 of the present embodiment will be described.
[0102] Figure 6 This is a schematic diagram for explaining an implementation example of an access request provided by the PLC 100 of the present embodiment. Figure 6 FIG. 4 shows an example in which an access command for accessing the database device 400 is defined in the user program 186. Figure 6 In the example of the access command, a "DB_INSERT" command for inserting data into the database device 400 is shown, but the present invention is not limited to this, and various commands including information for specifying target data to be sent to the database device 400 and a range of data to be accessed (access range) of the database device 400 can be specified. In this way, the access command includes information for specifying the access range for accessing the database device 400.
[0103] Typically, it is assumed that the user operates the support device 300 and specifies a DB access command (DB_INSERT) in the user program 186. When the user program 186 is executed and the execution timing of the DB access command is reached, the DB access processing library 191 ( Figure 4 ) corresponding command code, generates and sends an SQL statement containing an access request to the database device 400. That is, a DB connection service implemented by the DB access processing library 191 included in the system program 188 is provided, and the DB connection service is triggered along with the execution of the DB access command in the user program 186. Then, the DB connection service generates an SQL statement and sends the generated SQL statement to the database device via the driver software corresponding to the database device. Specifically, the DB access function is implemented through the upper communication controller 160 ( Figure 3 ) and DB access processing library 191 ( Figure 4 ) and sends the SQL statement generated by the DB connection service to the database device 400 via the network 112.
[0104] When receiving an SQL statement from the PLC 100 , the database device 400 executes processing according to the SQL statement and responds to the PLC 100 with the result as needed.
[0105] The DB connection service associates the content of the processing with the time information (i.e., as an execution log) according to the execution of the processing, and writes it into the operation log 184. In other words, a log of the operation status of the PLC 100 is saved. When the DB connection service generates and sends an SQL statement accompanying the execution of the access command, the content of the SQL statement is written into the operation log 184. Figure 6 In the illustrated example, the DB connection service updates the log file 1842 by appending the operation log 184 to the log file 1842 stored in the memory card 172 .
[0106] When an error occurs in the DB connection service accessing the database device 400, a log (hereinafter referred to as "failure log 1891") including the SQL statement when the access to the database device 400 fails is stored in the spool 189. Then, the DB connection service reads the SQL statement stored in the spool and resends it to the database device 400. At this time, the SQL statement to be resent to the database device 400 can be selected by using the user program 186 or a tool provided by the support device 300. The failure log 1891 is an error list that records the access request when the access to the database device 400 fails.
[0107] The spool is not limited to being provided inside the CPU unit 104, and the spool may be provided outside the CPU unit 104 (outside the PLC 100). The error list including the failure log 1891 may be stored in the memory card 172. Hereinafter, the storage area (spool or memory card) where the failure log 1891 is to be stored is referred to as a "save destination".
[0108] The support device 300 has a function for checking the contents of the operation log 184 . When some error occurs, the user can check the cause and contents of the error by using the function of the support device 300 .
[0109] <G. Issues in error recovery>
[0110] In order to recover when an error occurs in accessing the database device 400, it is conceivable to resend the SQL statements stored in the storage destination (e.g., spool). In the case of sending the SQL statements stored in the storage destination in batches, there is a possibility that undesired processing is executed. For example, it is assumed that the data insertion processing to the database device 400 fails multiple times. In this case, it is considered that the same data is inserted into the database device 400 multiple times when the SQL statements stored in the storage destination are sent in batches. Considering the case where the batch resending of SQL statements is not appropriate, it is preferable that the user program 186 is equipped with a function of resending only the specified SQL statements.
[0111] If the function of resending only the specified SQL statement is not installed in the user program 186, the user must refer to the log file (or the failure log file) to extract the SQL statement when the error occurred. However, there is a problem that it takes a lot of effort for the user to extract the SQL statement from the log. In addition, the user cannot send any SQL statement to the database device 400 via the DB connection service only by using the function of extracting the SQL statement from the log file.
[0112] In addition, when the storage destination is a spool and the capacity of the spool is small, the number of SQL statements that can be stored in the spool is also limited. Therefore, there is a possibility that the SQL statement that the user wants to execute is not stored in the spool.
[0113] In this embodiment, Figure 1 The access processing unit 4 shown extracts an access request that satisfies a predetermined condition from an error list that records access requests when access to the database device 400 fails. Then, the access processing unit 4 causes the communication interface 6 to resend the extracted access request. Therefore, only SQL statements that meet the conditions can be resent to the database device 400, so that a controller that can flexibly recover from a connection error with the database device 400 can be realized. The resending of SQL statements according to this embodiment will be described in detail below.
[0114] <H. Resending of SQL Statements in the First Mode of the Present Implementation>
[0115] Figure 7 1 is a schematic diagram showing the retransmission of SQL statements according to the first embodiment of the present invention. According to the first embodiment, the user program 186 determines a SQL statement that meets a specified condition, and instructs the DB connection service to extract and retransmit the determined SQL statement from a log file or a spool. The selection of the SQL statement by the user program 186 is performed, for example, during the operation of the PLC 100.
[0116] Reference Figure 8 , describing the structure and processing contents of the user program 186 used for SQL statement retransmission processing. Figure 8 1 is a diagram showing an example of the first function block FB1 included in the user program 186. Hereinafter, the function block FB1 is also referred to as a block FB1.
[0117] The program having the function of block FB1 may be defined by a method other than a function block. For example, block FB1 may include a block defined by a ladder diagram, a command list, a structured text, and a sequential function chart, or a block defined by a combination of these. In addition, block FB1 may include a block defined by a general-purpose programming language such as JavaScript (registered trademark) or C language.
[0118] The block FB1 is a program for executing a command for controlling access to the database device 400. More specifically, the block FB1 is a program having a function of instructing the DB connection program to reissue an SQL statement when an error occurs in access to the database device 400.
[0119] Block FB1 includes input units 255A to 255E for accepting settings related to reissuance of SQL statements, and an output unit 256A for outputting a command for executing reissuance of the SQL statement.
[0120] The input unit 255A indicated as "Execute" accepts a setting for specifying whether to execute the resending process of the SQL statement. As an example, the input unit 255A is specified to accept an input of the "BOOL" type. As long as "FALSE" is input to the input unit 255A, the resending of the SQL statement is not executed. On the other hand, when "TRUE" is input to the input unit 255A, the resending process of the SQL statement is executed.
[0121] Input units 255B, 255C, 255D, and 255E receive SQL types, areas, paths to areas, and extraction conditions, respectively. When processing is completed, output unit 256A indicating "Done" outputs a signal indicating a command to extract SQL statements that meet the extraction conditions from the area.
[0122] Fig. 9 is an example input to Figure 8 The information of the functional blocks is shown in the figure. Fig. 9 Examples of SQL types, areas, paths to areas, and extraction conditions are shown in FIG. Fig. 9 Example shown.
[0123] Fig.10 This is a sequence diagram showing the steps of retransmission processing of SQL statements in the first embodiment of the present invention. Fig.10 The sequence diagram shown shows, in addition to the internal processing of the PLC 100 , exchanges between the PLC 100 , the support device 300 , and the database device 400 .
[0124] At a certain timing, the user operates the support device 300 and selects a retransmission condition (sequence SQ100). By operating the support device 300, the user selects a retransmission condition to be input to the user program 186 (sequence SQ102). Specifically, the user selects an SQL type, an area, a path to the area, and an extraction condition via the support device 300. The support device 300 sends the information selected by the user to the PLC 100.
[0125] Next, PLC 100 executes user program 186. At this time, the input unit of function block FB1 receives information (SQL type, area, path to the area, and extraction condition) from support device 300. The output unit of function block FB1 sends a command to re-execute the corresponding SQL statement to system program 188 (DB connection service) (sequence SQ104).
[0126] In response to the command from the user program 186, the DB connection service issues an open command to open the error list (failure log file) stored in a storage destination such as a spooler (sequence SQ106). Next, the DB connection service issues a grep command to search the error list for a log containing a character string that meets the extraction condition (sequence SQ108). Thus, the DB connection service receives the result of executing the grep command from the storage destination (sequence SQ110). The following describes a case where a log containing a corresponding SQL statement is found in the error list.
[0127] The DB connection service creates a SQL statement to be resent based on the SQL statement contained in the extracted log (sequence SQ112). The DB connection service sends the SQL statement to the database device 400 and executes access to the database device 400 (sequence SQ114). The database device 400 executes processing according to the received access request and returns its execution result to the DB connection service (sequence SQ116).
[0128] As described above, in the first mode, the user program 186 (command execution unit 2) extracts the access request (SQL statement) that satisfies the condition based on the user input related to the setting of the specified condition, and the command access processing unit 4 (DB connection service) extracts the access request (SQL statement). In this way, only the SQL statement specified by the user can be extracted from the failure log, and only the processing related to the SQL statement can be executed again.
[0129] <I. Resending of SQL Statements in the Second Mode of the Present Embodiment>
[0130] Fig.11 This is a schematic diagram showing retransmission of SQL statements in the second mode of the present embodiment. In the second mode, the user program 186 extracts a log including SQL statements that meet the specified conditions from the failure log 1891 stored in the spooler 189. The user program 186 executes processing for displaying the log in the support device 300.
[0131] The support device 300 displays the information contained in the log by executing the tool software. The user selects the SQL statement to be resent from the displayed information. The support device 300 accepts the user input and sends an instruction for resending the SQL statement to the user program 186. The user program 186 determines the SQL statement that meets the specified conditions and instructs the DB connection service to extract and resend the determined SQL statement from the log file or spool. The resending of the SQL statement using the tool can be executed, for example, when the PLC 100 is started, or when the PLC 100 is maintained.
[0132] Reference Figure 12 to Figure 14, the structure and processing contents of the user program 186 for SQL statement extraction processing are explained. Fig.12 186 is a diagram showing an example of the second function block FB2 included in the user program 186. Hereinafter, the function block FB2 is also referred to as a block FB2.
[0133] Block FB2 is a program having a function of instructing the DB connection service to extract the SQL statement that should be resent. Block FB2 includes: input units 265A to 265E, which accept settings related to the extraction of SQL statements; and output units 266A and 266B, which are used to output commands for executing the extraction of SQL statements. Similar to block FB1, the input unit 265A represented as "Execute" accepts settings for specifying whether to execute the resending process of the SQL statement. As an example, the input unit 265A is specified to accept "BOOL" type input. As long as "FALSE" is input to the input unit 265A, the extraction of the SQL statement is not executed. On the other hand, when "TRUE" is input to the input unit 265A, the extraction process of the SQL statement is executed.
[0134] Input units 265B, 265C, 265D, and 265E receive SQL types, areas, paths to areas, and extraction conditions, respectively. When processing is completed, an output unit 266A indicated by "Done" outputs a signal indicating a command to extract SQL that meets the extraction conditions from the area. In addition, an output unit 266B indicated by "Handle" outputs a handle value.
[0135] Fig.13 186 is a diagram showing an example of the third function block FB3 included in the user program 186. Hereinafter, the function block FB3 is also referred to as a block FB3.
[0136] Block FB3 is a program having a function of executing the processing required for the support device 300 to display the failure log extracted from the storage destination. Block FB3 includes: input units 275A and 275B, which accept settings related to the acquisition of data; an output unit 276A, which is used to output a command for creating a list of acquired data; and an output unit 276B, which is used to output the extracted data. The input unit 275A represented as "Execute" accepts settings for specifying whether to create a data list. As an example, the input unit 275A is specified to accept "BOOL" type input. As long as "FALSE" is input to the input unit 275A, the creation of the data list is not executed. On the other hand, when "TRUE" is input to the input unit 275A, the creation of the data list is executed. The input unit 275B represented as "Handle" accepts the handle value from block FB2.
[0137] When the processing is completed, a signal indicating a command to create a data list is output from output unit 276A indicated by “Done.” In addition, information required for generating the list is output from output unit 276B indicated by “ExtractionInfo.”
[0138] Fig.14 186 is a diagram showing an example of a fourth function block FB4 included in the user program 186. Hereinafter, the function block FB4 is also referred to as a block FB4.
[0139] Similar to block FB1, block FB4 is a program having a function of instructing the DB connection program to resend the SQL statement when an error occurs in access to the database device 400. Block FB4 includes input units 285A and 285B for accepting settings related to resending the SQL statement, an output unit 286A for outputting a command for creating a list of acquired data, and an output unit 286B for outputting a command for executing the resending of the SQL statement.
[0140] The input unit 285A represented by "Execute" accepts a setting for specifying whether to execute the resending process of the SQL statement. As an example, the input unit 285A is specified to accept the input of the "BOOL" type. As long as "FALSE" is input to the input unit 285A, the resending process of the SQL statement is not executed. On the other hand, when "TRUE" is input to the input unit 285A, the resending process of the SQL statement is executed. The input unit 285B represented by "Handle" accepts the handle value from the block FB2.
[0141] When the processing is completed, a signal indicating a command to resend the SQL statement that meets the extraction condition is output from output unit 286A indicated by "Done".
[0142] Fig.15 This figure shows an example of a screen of a tool for accepting a selection of an SQL statement from a user. Fig.15 , the support device 300 executes the tool program, thereby Fig.15 The screen shown is displayed on the support device 300 . The tool 301 includes an SQL type selection unit 351 , an area selection unit 352 , a path selection unit 353 , and an extraction condition selection unit 354 .
[0143] The SQL category selection unit 351, the area selection unit 352, the path selection unit 353, and the extraction condition selection unit 354 are operated by the user. The SQL category selection unit 351 has a function of selecting the type of SQL category (SQL instruction). The area selection unit 352 has a function of selecting an area to store failure logs. The path selection unit 353 has a function of selecting a path to the area selected by the area selection unit 352. The extraction condition selection unit 354 has a function of selecting the condition of the SQL statement to be extracted. Fig.15 In the example shown, the SQL type ("INSERT"), the area ("execution log - failure log"), the path of the area (" / fs / MEMORYCARD / DBConnection"), and the extraction condition ("connection name = DBConnection 1") are selected.
[0144] The tool 301 further includes a SQL execution failure log display unit 355. The SQL execution failure log display unit 355 displays information included in the failure log in a table format. The items displayed by the SQL execution failure log display unit 355 include, for example, entry, date and time, SQL category, log code, log name, execution result, connection name, sequence ID, etc. The user operates the SQL execution failure log display unit 355 to reversely display the log containing the SQL statement to be reissued in the log displayed by the SQL execution failure log display unit 355, and select the log.
[0145] The tool 301 further includes an SQL display unit 356 and an SQL resend button 357. The SQL display unit 356 displays the SQL statement included in the failure log selected from the log displayed by the SQL execution failure log display unit 355. The SQL resend button 357 accepts the user's operation. By operating the SQL resend button 357, the tool 301 sends a command to the user program 186 to resend the SQL statement displayed by the SQL display unit 356 to the database device 400.
[0146] Fig.16 This is a sequence diagram showing the steps of retransmission processing of SQL statements in the second embodiment of the present invention. As in the first embodiment, at a certain timing, the user operates the support device 300 and selects a retransmission condition (sequence SQ100). By operating the support device 300, the user selects a retransmission condition to be input to the user program 186 (sequence SQ102). Specifically, the user selects an SQL category, an area, a path to the area, and an extraction condition via the support device 300. The support device 300 sends the information selected by the user to the PLC 100.
[0147] Next, PLC 100 executes user program 186. At this time, the input unit of function block FB2 receives information (SQL type, area, path to area, and extraction condition) from support device 300. The output unit of function block FB2 sends a command to extract the corresponding SQL statement to system program 188 (DB connection service) (sequence SQ104).
[0148] In response to the command from the user program 186, the DB connection service issues an open command to open the error list (failure log file) stored in a storage destination such as a spooler (sequence SQ106). Next, the DB connection service issues a grep command to search the error list for a log containing a character string that meets the extraction condition (sequence SQ108). Thus, the DB connection service receives the result of executing the grep command from the storage destination (sequence SQ110). The following describes a case where a log containing a corresponding SQL statement is found in the error list.
[0149] The DB connection service creates an SQL statement based on the extracted log (sequence SQ112 ) and then sends the execution result to the user program 186 (sequence SQ120 ).
[0150] The support device 300 sends a command to confirm the extracted content to the user program 186 in response to the user operation (sequence SQ122). In response to the command, the user program 186 (function block FB3) sends a command to display the extracted information to the DB connection service (sequence SQ124).
[0151] In response to the command, the DB connection service sends the execution result to the user program 186. As a result, the user program 186 acquires the extracted information (sequence SQ126). The support device 300 executes the program of the tool 301 so as to display the extracted information.
[0152] The user operates the tool 301 to select the SQL statement that should be reissued. The support device 300 instructs the PLC 100 to execute the reissue of the SQL statement. Accordingly, the function block FB4 instructs the DB connection service to reissue the SQL statement (sequence SQ130). The DB connection service sends the SQL statement to the database device 400 and executes access to the database device 400 (sequence SQ132). The database device 400 executes processing according to the received access request and returns its execution result to the DB connection service (sequence SQ134).
[0153] As described above, in the second mode, the user program 186 (command execution unit 2) executes the user program 186 (blocks FB2, FB3) for displaying information indicating the access request (SQL statement) extracted from the error list by the access processing unit 4 (DB connection service). The user program 186 (command execution unit 2) instructs the access processing unit 4 (DB connection service) to cause the communication interface 6 to resend the access request selected by the user based on the user input related to the selection of the access request. Therefore, as in the first mode, only the SQL statement specified by the user can be extracted from the failure log, and only the processing related to the SQL statement can be executed again.
[0154] <J. Prevention of erroneous retransmission>
[0155] When the user can select the SQL statement to be resent to the database device 400, the user may operate the tool to send the same SQL statement to the database device 400 multiple times. In such a case, there is a possibility that the same processing of the database device 400 is repeated multiple times. For example, the same data is inserted into the database device 400 multiple times. Therefore, when the processing of the database device 400 is successful by resending the SQL statement, it is preferable to prevent the same SQL statement from being further sent to the database device (preventing the erroneous resending of the SQL statement).
[0156] Fig.17 This is a sequence diagram showing the process for preventing the erroneous retransmission of SQL statements according to the present embodiment. Fig.17 , the sequence before SQ128 and Fig.16 The processing of sequences SQ132 and SQ134 is also the same as Fig.16 The processing of the corresponding sequences shown is the same.
[0157] The DB connection service receives the execution result from the database device 400 and checks the response of the database device 400. When the DB connection service receives a response indicating that the connection with the database device 400 is normal, the corresponding log (including the access request of the SQL statement) is deleted from the list of failed logs stored in the storage destination (sequence SQ140). In addition, in sequence SQ140, a process of invalidating the corresponding SQL statement may also be executed. For example, the value of the flag associated with the SQL statement may be set to a value indicating that the retransmission is successful.
[0158] On the other hand, when the DB connection service receives a response indicating that the connection with the database device 400 has failed, information indicating that the resending (RESEND instruction) of the SQL statement has failed is generated and the information is saved in the storage destination (sequence SQ142). Therefore, in this case, the SQL statement can be resent until the connection with the database device 400 is normalized.
[0159] As described above, according to this embodiment, an SQL statement to be reissued can be selected from a log (failure log) including an SQL statement when access to the database device 400 fails. Therefore, a connection error to the database device 400 can be flexibly recovered.
[0160] <K. Note>
[0161] As described above, this embodiment includes the following disclosure.
[0162] (Structure 1)
[0163] A controller (100) controls a control object, the controller (100) comprising:
[0164] A communication interface (6) for accessing a database device (400);
[0165] a command execution unit (2) for executing a user program (186) including an access command for accessing the database device (400) and associated with controlling the control object; and
[0166] an access processing unit (4) which generates an access request in response to the access command being executed by the command execution unit (2) and causes the communication interface (6) to send the access request,
[0167] The access processing unit (4) extracts an access request that satisfies a predetermined condition from an error list recording access requests when access to the database device (400) fails, and causes the communication interface (6) to resend the extracted access request.
[0168] (Structure 2)
[0169] In the controller (100) described in Configuration 1,
[0170] The command execution unit (2) instructs the access processing unit (4) to extract the access request satisfying the prescribed condition based on a user input related to setting of the prescribed condition.
[0171] (Structure 3)
[0172] In the controller (100) described in Configuration 1,
[0173] The command execution unit (2) executes the user program (186) for displaying information representing the access request extracted from the error list by the access processing unit (4), and instructs the access processing unit (4) to cause the communication interface (6) to resend the access request selected by the user based on user input related to the selection of the access request.
[0174] (Structure 4)
[0175] In the controller (100) described in any one of Structures 1 to 3,
[0176] The access processing unit (4) deletes the corresponding access request from the error list when the communication interface (6) successfully retransmits the access request.
[0177] (Structure 5)
[0178] In the controller (100) described in Structure 4,
[0179] When the communication interface (6) fails to retransmit the access request, the access processing unit (4) generates information related to the failure of the retransmission.
[0180] (Structure 6)
[0181] A control system, wherein the control system comprises:
[0182] A controller (100) according to any one of Structures 1 to 5; and
[0183] A database device (400) receives an access request from the controller (100).
[0184] (Structure 7)
[0185] A control method is a control method of a controller (100) for controlling a control object, the control method comprising the following steps:
[0186] The controller (100) executes an access command for accessing a database device (400);
[0187] The controller (100) generates an access request;
[0188] The controller (100) sends the access request to the database device (400);
[0189] The controller (100) saves the access request when the access to the database device (400) fails into an error list;
[0190] The controller (100) extracts access requests that meet specified conditions from the error list; and
[0191] The controller (100) resends the extracted access request to the database device (400).
[0192] The embodiments disclosed this time should be considered as illustrative in all aspects and not restrictive. The scope of the present invention is indicated by the claims rather than the above description, and is intended to include all modifications within the meaning and scope equivalent to the claims.
[0193] Description of symbols
[0194] 1: control system; 2: command execution unit; 4: access processing unit; 6: communication interface; 10: detection switch; 20: relay; 30: servo motor driver; 32: motor; 100: PLC; 102: power supply unit; 104: CPU unit; 106: IO unit; 108: PLC system bus; 110: field bus; 112: network; 114: connection cable; 120: processor; 122: chipset; 124: system clock; 126: main memory; 128: non-volatile memory; 130: communication connector; 140: PLC system bus controller; 14 2, 152, 162: buffer memory; 144: PLC system bus control circuit; 146, 156, 166: DMA control circuit; 148: PLC system bus connector; 150: field bus controller; 154: field bus control circuit; 158: field bus connector; 160: upper communication controller; 164: upper communication control circuit; 168: upper communication connector; 170: memory card interface; 172: memory card; 180: OS; 182: data definition information; 184: operation log; 1842: log file; 186: user program; 188: System program; 189: Spool; 1891: Failure log; 190: Sequence command library; 191: DB (database) access processing library; 192: Monitoring processing library; 193: Input and output processing library; 194: Tool interface processing program; 195: Scheduler; 200: Remote IO terminal; 202: Communication coupler; 208: Terminal bus; 255A~255E, 265A~265E, 275A, 275B, 285A, 285B: Input unit; 256A, 266A, 266B, 276A, 276B, 286A, 286B: Output unit; 300 : Support device; 301: Tool; 302: CPU; 304: ROM; 306: RAM; 308: Hard disk; 310: Keyboard; 312: Mouse; 314: Monitor; 316: CD-ROM reading device; 330: Support program; 332: CD-ROM; 351: Category selection unit; 352: Area selection unit; 353: Path selection unit; 354: Extraction condition selection unit; 355: Execution failure log display unit; 356: SQL display unit; 357: SQL resend button; 400: Database device; FB1~FB4: Function blocks; SQ100~SQ142: Sequence.
Claims
1. A controller, which controls a control object, and has: A communication interface for accessing a database device; a command execution unit that executes a user program that includes an access command for accessing the database device and is associated with control of the control object; and an access processing unit that generates an access request in response to the access command being executed by the command execution unit, and causes the communication interface to send the access request, The access processing unit extracts an access request including a character string that meets an extraction condition from an error list recording access requests when access to the database device fails, and causes the communication interface to resend the extracted access request. The command execution unit instructs the access processing unit to extract the access request satisfying the extraction condition based on a user input related to setting of the extraction condition.
2. The controller according to claim 1, wherein: The command execution unit executes the user program for displaying information representing the access request extracted from the error list by the access processing unit, and commands the access processing unit to cause the communication interface to resend the access request selected by the user based on user input related to the selection of the access request.
3. The controller according to claim 1 or 2, wherein: The access processing unit deletes the corresponding access request from the error list when the communication interface successfully retransmits the access request.
4. The controller according to claim 3, wherein: The access processing unit generates information on the failure of the retransmission when the communication interface fails to retransmit the access request.
5. A control system, wherein: The control system includes: The controller according to any one of claims 1 to 4; and The database device receives an access request from the controller.
6. A control method, which is a control method of a controller for controlling a control object, the control method comprising the following steps: The controller executes an access command for accessing a database device; The controller generates an access request; The controller sends the access request to the database device; The controller saves the access request when the access to the database device fails into an error list; The controller retrieves the error list according to a user input related to setting of extraction conditions; The controller extracts the access request including the character string meeting the extraction condition from the error list; as well as The controller resends the extracted access request to the database device.
Citation Information
Patent Citations
Data collection system, and abnormality factor determination method of data collection system
JP2012108642A
Controller and information processing device
JP2014157483A
Controller and program
US20140136570A1
