Advanced Training Manual for MCGS Configuration Software
Thread Content
Introduction: After completing the basic training, you now have a general understanding of the framework structure of the MCGS configuration software. With the guidance provided in the basic training materials, you should be able to configure some simple engineering projects, but you may still face difficulties if you want to use it proficiently. With the help of advanced training materials, you will surely be greatly empowered to configure satisfactory engineering projects. Training Objectives: After completing the training, you will be able to use all the functions in the MCGS configuration software proficiently ; Able to skillfully create animation workflows based on the requirements of the production site ; It can handle relatively complex requirements such as curves, reports, and data post-processing ; Capable of using MCGS script programs to control complex industrial processes proficiently. Training topics include animation production, process control strategies, device configuration, creating complex historical reports using stored data, the application of formula components, and tips for using MCGS. Reference manuals: “MCGS User Guide”, “MCGS Reference Manual”, MCGS multimedia tutorials, online help for MCGS industrial control configuration software, and others. E-mail: mcgs@mcgs.com.cn Website: www.mcgs.com.cn Table of contents... 1 Contents... 2 Lecture 1: Creating Real-Time Databases... 5 1. Overview of MCGS real-time databases... 5 2. Types of data objects... 6 1) Switch-type data objects... 6 2) Numeric data objects... 6 3) Character-type data objects... 6 4) Event-type data objects... 7 5) Data group objects... 7 3. Definition of data objects... 8 4. Scope of data objects... 9 Lecture 2: Animation Creation... 10 1. Creating covers... 10 2. Animation effects... 15 Lecture 3: Configuration of Device Windows... 17 1. Overview... 17 2. Supported hardware devices... 19 1) Intelligent modules... 19 2) Acquisition cards... 20 3) Intelligent instruments... 20 4) Frequency converters... 21 5) PLCs... 21 3. Online debugging of devices... 22 4. Data preprocessing... 27 Lecture 4: Script Programs... 32 1. Elements of script programming language... 32 1) Data types... 32 2) Variables and constants... 32 3) MCGS objects... 33 4) Expressions... 33 5) Operators... 33 6) Operator precedence... 34 2. Basic statements in script programs... 35 1) Assignment statements... 35 2) Conditional statements... 35 3) Exit statements... 36 4) Comment statements... 36 3. Applications and examples of script programs... 36 1) Use of script programs in “windows”... 37 2) Use of script programs in “standard buttons”... 40 3) Use of script programs in “menus”... 45 Lecture 5: MCGS Data Post-Processing and Reporting... 48 1. Data post-processing... 48 2. Creating complex reports using data extraction... 49 1) Creating a new window... 49 2) Simulating required data... 50 3) Extracting data at intervals... 58 4) Extracting data based on different methods... 67 5. Results of data extraction... 72 Lecture 6: MCGS Formula Components... 76 1. Basic principles of MCGS formula management... 76 2. Using MCGS formula components... 76 1) Formula configuration design... 77 2) Formula operation design... 80 3. Dynamically editing formulas... 87 Lecture 7: Tips for Using MCGS... 88 Lecture 1: Creating Real-Time Databases 1. Overview of MCGS real-time databases In MCGS, data differs from traditional data or variables; it not only includes the numerical values of variables but also encapsulates other attributes related to the data (such as data status, alarm limits, etc.) as well as methods for operating on the data (such as saving to disk, handling alarms, etc.), providing services in the form of objects. Such data, which integrates values, attributes, and methods, is called a data object. MCGS uses data objects to represent real-time data in the system, replacing traditional value variables with object variables. A collection of all data objects managed using database technology is called a real-time database. The real-time database is the core of MCGS and serves as the data processing center for application systems. As shown in the figure below, all components of the system exchange data through this real-time database as a common area, thereby enabling coordinated operation among them. The device window drives external devices through device components, and sends the collected data to a real-time database ; A graphical object composed of user windows, which establishes a connection with data objects in a real-time database to visualize the data in an animated format ; The execution strategy operates on and processes data through policy components. Note: In MCGS, data is represented by \"data objects\"; these can be considered as object variables with more functions than traditional variables. Data objects can be used in the same way as variables, and in most cases, it is sufficient to use the name of the data object to operate on it directly. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image002.jpg II. Types of data objects In the MCGS configuration software, data objects come in five types: on/off type, numeric type, character type, event type, and group object type. Different types of data objects have different attributes and different uses. In the introductory training materials, we have already learned to define three types: switch-type, numeric-type, and group-object type. 1. Switch-type data objects: Data objects that record switch signals (0 or non-0) are known as switch-type data objects. They are typically connected to the digital input/output channels of external devices, and are used to indicate the current state of a particular device. Switch-type data objects are also used to represent the status of a certain object in MCGS, such as the visibility status of a graphic object. Switch-type data objects do not have engineering units, maximum and minimum value attributes, or limit alarm attributes; they only have status alarm attributes. 2. In the MCGS configuration software, for numeric data objects, the range of values is as follows: negative numbers range from -3.402823E38 to -1.401298E-45, while positive numbers range from 1.401298E-45 to 3.402823E38. In addition to storing values and participating in numerical calculations, numeric data objects also provide alarm information and can be connected to the analog input/output channels of external devices. Numeric data objects have maximum and minimum value attributes, and their values do not exceed the set range. When the value of an object is less than the minimum value or greater than the maximum value, its value is set to either the minimum value or the maximum value, respectively. Numeric data objects have limited-value alarm properties, allowing the setting of six types of alarm limits: lower minimum, minimum, maximum, upper maximum, upper deviation, and lower deviation. An alarm is generated when the value of the object exceeds these set limits ; The alarm is cleared when the object’s value returns within all limits. 3. Character data objects: Character data objects are units used to store text information; they are employed to describe the state characteristics of external objects. Their values are strings composed of multiple characters, with a maximum length of 64KB. Character data objects do not have engineering units, maximum or minimum value attributes, nor alarm attributes. 4. Event-based data objects: Event-based data objects are used to record and identify the timing information of when a certain event occurs or when its state changes. For example, changes in the state of digital switches, user button presses, and the generation of alarm messages can all be considered as events occurring. Information about the event can be obtained directly from a certain type of external device, or it can be provided by corresponding internal functional components. The value of an event-type data object is a fixed-length string of 19 characters, used to record the time when the most recent event occurred: \"year, month, day, hour, minute, second\". The year is represented by four digits, while the month, day, hour, minute, and second are each represented by two digits, separated by commas. For example, “1997,02,03,23,45,56” indicates that the event occurred on February 3, 1997, at 23:45:56. When the corresponding event does not occur, the value of that object is fixed at “1970,01,01,08,00,00”. Event-type data objects do not have engineering units, maximum or minimum value attributes, nor limit alarms; they only have status alarms. Unlike switch-type data objects, an event corresponding to an event-type data object occurs once, and its alarm is generated once as well, with the generation and termination of the alarm taking place simultaneously. 5. Data group objects: Data group objects are a special type of data object introduced by MCGS. Similar to arrays and structures in regular programming languages, they are used to gather multiple related data objects together so that they can be defined and processed as a single entity. For example, in introductory textbooks, the operating state of a water level control system is described using two physical quantities: Level 1 and Level 2. To simplify processing, a \"Level Group\" is defined as a group object that represents the actual physical entity of \"water level.\" Its internal members consist of the data objects corresponding to these physical quantities. Thus, when processing the \"water level\" object (such as saving configurations, displaying curves, or showing alarms), it is sufficient to specify the name of the group object, \"Level,\" which encompasses the processing of all its members. Group objects are merely a way of representing a category of objects as a whole during configuration; actual operations are carried out on each individual member. For example, in the alarm display animation component, if the data object for which alarms are to be displayed is specified as the group object “Liquid Level,” then this component will show all the alarm messages generated by the various data objects within that group object during operation. A data group object is a collection of single data objects; it must contain two or more data objects, but it cannot contain other data group objects. A data object can be a member of multiple different group objects. After defining the type of an object as a group object, it is also necessary to define the members that the group object contains. As shown in the figure below, within the “Group Object Property Settings” dialog box, there is a dedicated “Group Object Members” tab used to define the members of a group object. On the left side of the diagram is the list of all data objects, while on the right side is the list of members of the group objects. Using the “Add” button on the property page, the specified data object on the left can be added as a member of the group object ; “The “Delete” button removes the members of the group object specified on the right. Group objects do not have engineering units, maximum value, or minimum value properties, and they also lack alarm properties of their own. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image004.jpg III. Definition of data objects The table below lists the names of the variables used in the advanced training materials. Variable Name Type CommentDate Character Displays the system date
Time Character Displays the system time
Stone chips Numerical Value One of the materials used in recipe operations
Gravel Numerical Value One of the materials used in recipe operations
Pumpkin seeds Numerical Value One of the materials used in recipe operations
Fly ash Numerical Value One of the materials used in recipe operations
Lime Numerical Value One of the materials used in recipe operations
Recipe library operations Numerical Value Used for performing operations on the recipe library, such as editing, loading, and querying
Recipe number Character A variable used for querying recipes in recipe operations
Recipe query number Character A variable used for querying recipes in recipe operations
Angle Numerical Value A variable used for animations in the cover window
Counter 1 Numerical Value Displays the value of Counter 1
Counter 1 time display Character Used to display the value of Counter 1 in clock format
Counter 1 operation status Switch Used to start or stop Counter 1
Timer 1 maximum value Numerical Value Used to limit the maximum value that Counter 1 can count to
Data 1 to Data 5 Numerical Value Used to generate data during data extraction
Data display 1 to 4 Numerical Value Used to display the hexadecimal values resulting from character conversion to ASCII codes
Data input Numerical Value Used to enter numbers between 0 and 9999
String display Character Used to display the string resulting from the conversion of input data
String decomposition 1 to 4 Character Used to display the characters resulting from string decomposition
Data display 1 to 4 can be added in groups. The procedure is as follows: In the “Real-time Database”, click the “Add in Groups” button on the right; this will bring up the “Add Data Objects in Groups” dialog box, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image006.jpg
4. Scope of data objects: The data objects defined in the real-time database are global in nature; all parts of MCGS can operate on these data objects, using them to exchange information and coordinate tasks. The various attributes of the data object remain valid throughout the entire operation. For example, in a water level control system, for levels 1 and level 2, the same variable is used in real-time curves, real-time reports, animated workflows, etc. Lecture 2: Animation Production I. Cover Creation The cover window is the first graphical interface that appears after the project is launched; the style of the cover window for a demonstration project is shown in the figure below. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image008.jpg On the MCGS configuration software development platform, click on “User Window” to enter it, then click the “Create New Window” button to create “Window 0”. Select “Window 0” and click the “Window Properties” button; the “User Window Properties” settings window will appear as shown. After making the necessary settings, click the “OK” button to exit. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image010.jpg 3D text is created by overlapping two text tags with different colors and no background (the background color matches that of the window). Here, we first need to understand a concept, namely the concept of “layer”. By layer, it is meant the order in which graphics are displayed; objects located on a higher \"layer\" will inevitably cover those on lower layers. Applied to us, this means using text of two different colors; they are located on different \"layers\" (with different order of display) and also have different X-Y coordinates. The key point is: create a text label diagram, enter text within it, and use the \"copy\" function to replicate another text diagram; aside from having different font colors, the two text diagrams have exactly the same properties. The two text boxes overlap each other; by using the layer adjustment buttons on the toolbar, one can change their order and relative positions so that the text above covers part of the text below, creating a 3D effect. To achieve the 3D text effect of the “MCGS Configuration Software Demo Project” shown in the figure above, follow the settings in the figure below: place those with a color of “black” at the bottom and those with a color of “white” at the top, then adjust them using the up, down, left, and right buttons. The same method is applied to create the “Welcome” text. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image012.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image014.jpg To make the “MCGS Configuration Software Demo Project” flash during operation in order to add an animation effect, set it as shown in the figure below; set the expression to 1, which means the condition is always true. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image016.jpg In the “Cover Window,” there is a black, frameless rectangle in the upper left corner, and a white, frameless rectangle in the upper right corner; these are created using the “Labels” option in the “Toolbox.” The upper left corner displays the current date when the program is running, while the upper right corner shows the current time. The date attribute is set as shown in the figure below. The clock attribute is set in a similar manner to the date attribute; all that needs to be done is to replace \"date\" with \"time\" in the expression for \"display output\". file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image018.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image020.jpg There is a large ellipse in the “cover window”, along with a small ball; during operation, the ball moves continuously around the circumference of the ellipse in a clockwise direction. The specific steps are as follows: Select the \"Ellipse\" option from the \"Toolbox\", drag it to the desktop, adjust its size to 480×200, and set the \"Fill Color\" to \"Lime Green\". Click “Status Bar” in the “View” menu to open it; its size can be adjusted based on the area in the lower right corner. The size of the ball is set to 28×28, and it is located at the center of the ellipse. Its positioning and attribute settings are shown in the following images: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image022.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image024.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image026.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image028.jpg On the MCGS configuration software platform, click “Run Strategy”, then double-click on “Loop Strategy” or select “Loop Strategy” and click “Strategy Configuration” to enter the strategy configuration interface. Click the \"Add Policy Row\" file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image030.jpg icon on the toolbar to add a new policy row. Next, select \"Script\" from the \"Strategy Toolbox\" and drag it to the strategy line at file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image032.jpg. Click the left mouse button; as shown in the figure, set the cycle time to 200ms. Double-click on file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image034.jpg to enter the script editing environment, and enter the following code: Angle=Angle+3.14/180*2 IF Angle>=3.14 THEN Angle=-3.14 ELSE Angle=Angle+3.14/180*2 ENDIF Date=$Date Time=$Time Change “Label” to: Cover Animation Date and Time. II. Animation effects: On the MCGS configuration software development platform, click to enter the “Main Control Window”. Select the “Main Control Window”, then click the “System Properties” button. The “Main Control Window Properties Settings” dialog box will appear; the specific settings are shown in the figure. Under “Basic Properties”, set the “Cover display time” to 30 seconds, and select “Cover Window” for the “Cover Window” option. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image038.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image040.jpg Press “F5” to enter the operating environment; the first window that appears is the “Cover Window”. If no actions are taken with the keyboard or mouse, the Cover Window will operate automatically for 30 seconds before moving on to the “Water Level Control” window; otherwise, the “Water Level Control” window is accessed immediately. The output image is: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image042.jpg Lecture 3: Configuration of Device Windows I. Overview The device window is an important component of the MCGS system; it is responsible for establishing connections between the system and external hardware devices, enabling MCGS to read data from these devices and control their operation status, thereby allowing for real-time monitoring of industrial processes. The basic method for implementing device drivers in MCGS is to configure various types of device components within the device window, and to set relevant attributes based on the type and characteristics of the external device. The operations related to the device, such as hardware parameter configuration, data conversion, and device debugging, are encapsulated within these components, thereby establishing a data transmission channel with the external device in the form of objects. During operation, the device components are uniformly managed and coordinated through the device interface; they transmit data collected from external devices to the real-time database via connection channels, retrieve control parameters from this database, and send them to other parts of the system for control calculations and process scheduling. This enables real-time monitoring of the device’s operating status as well as automatic control of the processes. This structural design of MCGS makes it a device-independent system; for different hardware devices, it is sufficient to customize the corresponding device components, place them in the device window, and set the relevant properties, after which the system can operate on that device without any need to modify the overall system structure. In the standalone version of MCGS, a single user project allows only one device window, which is located within the main control window. At runtime, the main control window is responsible for opening the device window. The device window is an invisible window that operates in the background, responsible for managing and scheduling the operation of device driver components. Due to MCGS’s open architecture for handling devices, it is possible in practical applications to easily customize and add the necessary device components, thereby continuously expanding the device toolkit. MCGS will gradually provide device components corresponding to commonly used industrial control products both domestically and internationally. At the same time, MCGS also offers interface standards to enable users to develop the required device components using programming tools such as Visual Basic or Visual C++, which can then be added to MCGS’s device toolbox. MCGS provides an advanced development wizard that can automatically generate a framework for device drivers for users. To enable ordinary engineering users to quickly customize and develop specific device drivers, the MCGS system also provides the source code for typical system device drivers; users can modify these source codes to create their own device drivers. For the already prepared device drivers, MCGS uses a device component management tool to handle them. By clicking on \"Device Component Management\" in the \"Tools\" menu of MCGS, a \"Device Management\" window will appear, as shown in the following image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image044.jpg. The main function of this device management tool is to enable users to quickly find the appropriate device driver among hundreds of available options, as well as to register or remove the selected devices from Windows. The registration and deletion of MCGS device drivers must be carried out in the following manner before using an MCGS device for the first time or creating a new device by the user; otherwise, unpredictable errors may occur. Method for registering device drivers: As shown in the figure, all devices currently supported by MCGS are listed on the left side of the window, while all devices that have been registered are listed on the right side. The user only needs to select the device to be used from the list on the left side of the window and click the “Add” button to complete the registration of that MCGS device. To delete a MCGS device, the user selects it from the list on the right side of the window and clicks the “Delete” button. For selecting MCGS device drivers, as shown in the figure, all of MCGS’s devices are listed in the list box on the left side of the window (all devices located in the MCGS \\Program\Derives directory). The available devices are arranged according to a certain classification method, allowing users to find the devices they need by using this classification system. For example, if a user wants to find the driver for the Kontron IPC‑5488 data acquisition module, they first need to locate the directory containing those data acquisition modules, then find the directory specific to Kontron cards within that folder, and finally the Kontron IPC‑5488 driver can be found there. Pressing the install button allows you to install devices from other directories (other than the MCGS \\Program\Derives directory). The classification method for MCGS device catalogs is designed to enable users to quickly find the desired device drivers among the many available ones. All of MCGS’s device drivers are arranged according to a logical classification system, as shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image046.jpg II. Supported hardware devices 1. Intelligent modules MCGS 5.1 supports the following intelligent modules: l Advantech ADAM4000 series, ADAM5000/485 series, ADAM5000/CAN series ; l Advantech Adam 4000 series l Weida 7000 series l Poyi NuDAM 6000 series l Zhongtai RM series l Huakong Little Sparrow series 2. Acquisition cards: MCGS 5.1 supports acquisition cards from the following series: l Contek IPC series l Advantech PCL series, PCI series l Zhongtai PC series l Advantech PCL series l Tongwei ACL series l Huakong HY series 3. Intelligent instruments: MCGS 5.1 supports intelligent instruments from the following series: l Kunlun Tianchen weighing instruments (TCCH), timer instruments (TCDSQ), timers, multi-channel digital display instruments (TCDSX), multi-channel digital display instruments, integral calculation instruments (TCJS), integral calculation instruments, counter instruments (TCJSQ), counters, PID controllers (TCPID), large-screen display instruments (TCSHOW), digital display instruments (TCSX), inspection instruments (TCXJ), dual-display instruments (TCSXD-2), integral calculation instrument XSJ, integral calculation instrument TCXSJM, 16-point digital input/output devices TCXSK, single-display instruments TCXST, linear speed instruments TCXSY, rotational speed instruments TCZS ; l Zhejiang University Zhongkong series of paperless recorders such as JL22A/B, JL22M, JL26A/B, JL30A/B, etc ; l Japanese island electric meters such as SR21, SR25, SR73A, SR74A, etc ; l Xiamen Yuguang AI-808, AI-708M and other instruments ; l **Hongrun WP series: Type I display (A-01), Type II display (B-01), frequency display (A-02), counter (A-03), four-alarm display (A-04), 4.5-digit display (A-05), dual-input display (A-07), 32-segment PID program (A-10), PID self-tuning (A-20), flow accumulation (A-26), flow accumulation (A-27), level-volume (A-28) and other controllers ; l **Shangrun WP series: Type I display (A-01), Type II display (B-01), frequency display (A-02), counter (A-03), four-alarm display (A-04), 4.5-digit display (A-05), dual-input display (A-07), 32-segment PID program (A-10), PID auto-tuning (A-20), flow accumulation (A-26), flow accumulation (A-27), level-volume (A-28) and other controllers ; l Toledo Panther series electronic scales ; L Shimai CB900 series electronic scale ; l Honeywell UMC800 controller ; l Omron E5CN series instruments ; l European EUR series instruments ; 4. The inverter MCGS 5.1 supports the following inverters: l Siemens inverters, l Lenze inverters, l AB inverters, l Huawei inverters, l Delta inverters. 5. The PLC MCGS 5.1 supports the following series of PLC devices: l Siemens S7_200 (free port, PPI interface), S7_300 (MPI interface, Profibus interface), S7_400 (MPI interface, Profibus interface) ; l Modicon Modbus-RTU protocol, Modbus-ASCII protocol, Modbus-Plus protocol ; l Omron-CQM series, C200 series, CS series, and CV series ; l Mitsubishi FX series, AnA series l **FP0, FP1, up to FP10 series. l Delta SC500/OMC-1 series, Open_PLC XC_2000 series l LG_LG_MK_S series ; l GE_90 series l AB full series l Fuji NB series and Hilscher full series. III. Online equipment debugging: Using Siemens S7200 PLC as an example, we will show you how hardware devices are connected to the MCGS configuration software. The specific steps are as follows: On the MCGS configuration software development platform, click on “Device Window”, and then click on the “Device Configuration” button to enter device configuration. Click \"Toolbox\" from the \"Toolbar\" to bring up the \"Device Toolbox\" dialog box. Click the “Device Management” button, and the “Device Management” dialog box will appear. From the \"Optional Devices\" list, double-click on \"General Devices\", find \"Serial Communication Parent Device\", double-click on it. Select \"Serial Communication Parent Device\" under it and either double-click or click the \"Add\" button to add it to the selected devices on the right side. Double-click on “PLC Devices”, find “Siemens”, double-click on it, then double-click on “S7‑200‑PPI”. Select “Siemens S7‑200PPI” and either double-click or click the “Add” button to add it to the list of selected devices on the right. As shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image048.jpg Click the “OK” button to return to the “Device Toolbox”, as shown in: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image050.jpg Double-click “Serial Communication Parent Device” in the “Device Toolbox”, and then double-click “Siemens S7-200PPI”, as shown in: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image052.jpg Double-click “Device 1 – Serial Communication Parent Device”, and the “Device Properties Settings” dialog box will appear; make the settings according to the actual situation. The default parameters for Siemens are: baud rate of 9600, 8 data bits, 1 stop bit, and even parity. Once the parameters are set, click the “Confirm” button to save them. If this is your first time using it, please click the “Help” button or select “View Online Help for the Device”, then click the file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image053.gif icon to open the “MCGS Help System”; please read it carefully. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image055.jpg The serial port of a computer is one of the most commonly used communication interfaces for connecting a computer with other devices. Multiple communication devices can be connected to a single serial port (for example, 255 ADAM communication modules can be connected to an RS485 bus, but they all share one parent device for serial communication). To accommodate the various ways in which serial ports can be used, the MCGS configuration software employs a communication mechanism in which multiple subordinate communication devices are connected to a parent serial communication device; each subordinate device inherits some of the common attributes of the parent device, while also having its own unique attributes. In practical operation, MCGS provides a serial communication parent device component and multiple communication child device components. The serial communication parent device component handles the basic operations and parameter settings related to the serial port, while the communication child device components serve as the drivers for the devices actually connected to the serial port. The S7-200PPI component is used for MCGS operations and for reading and writing data or status from various registers of Siemens S7_21X, S7_22X series PLC devices. This component uses the Siemens PPI communication protocol; it can communicate with PLCs in a convenient and fast manner by utilizing standard Siemens PC\PPI communication cables or generic RS232/485 converters. Double-click on Siemens S7-200PPI, and the “Device Attribute Settings” dialog box will appear. As shown in the figure, it is recommended that you first read the “MCGS Help System” carefully to understand how to operate the Siemens S7-200PPI within the MCGS configuration software before setting its attributes. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image057.jpg Select \"Set device internal properties\" under \"Basic properties\"; the file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image053.gif icon will appear. Click on that icon, and the \"Siemens S7‑200 PLC Channel Properties Settings\" dialog box will be displayed. As shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image059.jpg Click “Add Channel”; the “Add Channel” dialog box will appear. After making the necessary settings, click the “OK” button. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image060.gif The components of Siemens S7_200 PLC devices divide the PLC’s channels into three categories: read-only, write-only, and read-write. Read-only mode is used to transfer data from the PLC into MCGS’ real-time database, while write-only mode is used to transfer data from MCGS’ real-time database to the PLC. Read-write mode allows data to be both read from and written to the PLC. When the device is started up for the first time, the data in the PLC is read back; thereafter, if MCGS does not change the values of the registers, the values from the PLC are read back. If MCGS wants to change the current value, it writes the value to the PLC. The purpose of this operation is to prevent the data in certain channels within the user’s PLC program from failing to be reset when the computer starts up for the first time or if the computer crashes midway; it also helps to reduce the number of variables required. “The channel connection is set as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image062.jpg. Online debugging of the “Siemens S7-200PPI” can be carried out in “Device Debugging”, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image064.jpg. If the “Communication Status Flag” is 0, it indicates normal communication; otherwise, communication between the MCGS configuration software and the Siemens S7-200 PLC device fails. If communication fails, troubleshoot it as follows: 1. Check whether the PLC is powered on. 2. Check whether the PPI cable is functioning properly. 3. Verify whether the actual address of the PLC matches the address on the basic attributes page of the device component. If the actual address of the PLC is unknown, use the search tool in the programming software to check it; if it exists, the PLC’s address will be displayed. 4. Check whether the operation on a certain register is out of range. For other devices such as circuit boards, modules, instruments, PLCs, etc., before debugging them using the MCGS configuration software, please read the hardware usage instructions and the MCGS online help system in detail. IV. Data Preprocessing: In practical applications, it is often necessary to process the data collected from devices or the data sent to devices in order to obtain the engineering physical quantities required. For example, the data acquired from AD channels is usually in the form of voltage values in millivolts; range conversion, table lookup, calculations, and other processes are needed to derive the desired engineering physical quantities. The MCGS system can perform eight types of data processing on the data collected by the device’s acquisition channels, including: polynomial calculations, reciprocal calculations, square root calculations, filtering, engineering unit conversions, function calls, standard table lookups, and custom table lookups. These various processing operations can be carried out individually or in combination. Data preprocessing in MCGS is closely related to devices; within the MCGS device window, by opening the device components and setting their data processing property pages, configuration for data preprocessing in MCGS can be carried out. As shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image066.jpg. By clicking the “Settings” button, the “Channel Processing Settings” window is opened, where the configuration for data preprocessing is carried out, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image068.jpg. In the MCGS Channel Processing Settings window, the configuration settings for data preprocessing are made. For example, to convert the input signal of 1000–5000 mV (the signal collected by device channel 3) into a humidity value within the range of 0–100 RH (the sensor’s measurement range), the fifth conversion option should be selected; the settings are as shown in: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image070.jpg In its operating environment, MCGS uses linear interpolation to convert the input signal into a physical value within the range of 0–100 RH. The eight methods for data preprocessing in MCGS are explained as follows: l Polynomial processing: Polynomials are used to apply polynomial (coefficient) transformations to the channel signals of the device. The process parameters that can be set range from k0 to k5; these can be set as constants or as values specific to a certain channel (by adding a “!” in front of the channel number). In addition, it is necessary to select the multiplication or division relationship between the parameter and the input value X. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image072.jpg l Inverse 1/X: Performs an inverse operation on the signal input to the device. l Square root: Perform a square root operation on the device’s input signal. l Filtering: Also known as median filtering, it uses 1/2 of the current input signal from the device plus 1/2 of the previous input signal. l Engineering conversion: Converts the device’s input signal into engineering physical quantities. l Function call: Function calls are used to perform statistical calculations on multiple set channel values, including summing, averaging, finding the maximum value, finding the minimum value, and calculating the standard deviation. Furthermore, it is also possible to use dynamic link libraries to develop one’s own calculation algorithms and integrate them into MCGS, thereby enabling the free expansion of MCGS’s algorithms. As shown in the figure, it is necessary to specify the path and filename of the dynamic link library containing the user-defined function, as well as the name of the custom function. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image074.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image076.jpg Standard table lookup calculations: As shown in the figure below, standard table lookup calculations include those for eight commonly used thermocouples as well as the Pt100 thermal resistor. Before consulting the table for the Pt100 thermistor, the voltage value acquired through the AD channel must first be converted into the resistance value of Pt100 using other methods; thereafter, the corresponding temperature value can be determined by referring to the table based on that resistance value. For calculation using a lookup table with thermocouples, it is necessary to specify the channel to be used for temperature compensation (temperature compensation is not required if the thermocouple has already been compensated at the freezing point). Before performing the lookup table calculation, the values collected from the channel used for temperature compensation must first be converted into actual temperature values, while the values collected from the thermocouple channel must be converted into actual millivolt values. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image078.jpg l Custom table lookup calculation processing: As shown in the figure below, for custom table lookup calculation processing, it is first necessary to define a table, with corresponding values entered in each row ; Then specify the lookup reference. Note: MCGS requires that each column of data used for lookup calculations be arranged in a monotonically increasing or decreasing order; otherwise, lookup calculations cannot be performed. As shown in the figure below, the reference for lookup is the first column. When processing in the MCGS system, the device input signals are first linearly interpolated with respect to this reference (the first column); the second column shows the corresponding engineering physical quantity, that is, the reference input signal and its corresponding engineering physical value (the sensor’s range). file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image080.jpg Lecture 4: Script Programs. This lecture introduces the syntax rules of MCGS script programs, the editing environment, the programming statements and internal functions available, as well as the situations in which script programs can be used, enabling users to quickly understand and master how to create their own script programs. User script programs are programs created by users to carry out specific operations and tasks. The programming syntax of these scripts is very similar to that of ordinary Basic language, but they are simpler and more intuitive in terms of concept and usage, aiming to enable most ordinary users to master and use them correctly and quickly. For most simple application systems, simple configuration in MCGS is sufficient. Only relatively complex systems require the use of script programs, but writing them correctly can simplify the configuration process, **improve work efficiency, and optimize the control process. I. Elements of Scripting Programming Languages 1. Data types: Boolean – values are 0 or 1; Numeric – values range within 3.4E±38; Character – values are strings consisting of up to 512 characters. 2. Variables and constants: In scripting programs, users cannot define their own variables, nor can they create subroutines or functions. Operations can only be performed on data objects in the real-time database; the values of these data objects are read and written using their names, and it is not possible to manipulate other attributes of the data objects. Data objects can be regarded as global variables in a script program, shared across all program segments. The three data objects—switch type, numeric type, and character type—correspond to the three data types in script programs. In script programs, read and write operations cannot be performed on group objects and event-based data objects, but group objects can be saved to disk. Constants: Boolean constants, which are numbers 0 or 1; numeric constants, which are values with or without a decimal point, such as 12.45, 100; string constants, which are strings enclosed in double quotes, such as “OK”, “Normal”. Internal system variables: The internal data objects defined by the MCGS system serve as internal variables that can be used freely in script programs. When using internal variables, the “$” symbol must be placed before the variable name, such as $Date. For more details on internal variables, please refer to the chapter on internal variables in the User Reference Manual or the list of internal variables in the online help. System internal functions: These are internal functions defined by the MCGS system, which can be used freely in script programs. When using an internal function, the “!” symbol must be placed before it, for example, !abs(). For more details on internal functions, please refer to the chapter on internal functions in the User Reference Manual or the list of internal functions available in the online help. 3. MCGS objects: MCGS operation objects include user windows, user policies, and device components in a project. These objects cannot be used as variables or expressions in script programs, but they can be used as parameters for internal system functions, such as ! Setdevice(device 0, 1, “”). 4. An expression is an arithmetic formula composed of data objects (including those defined by the designer in the real-time database, internal system data objects, and internal system functions), parentheses, and various operators; the result of calculating an expression is called the value of that expression. When an expression contains logical operators or comparison operators, its value can only be 0 (the condition is not met, false) or non-0 (the condition is met, true); such expressions are called logical expressions ; When an expression contains only arithmetic operators and its result is a specific numerical value, such expressions are called arithmetic expressions ; Constants or data objects are expressions in the narrow sense, whose values correspond to the value of those individual quantities. The type of the expression value is the type of the expression itself, and it must be one of the three types: switch, numeric, or character. Expressions are the most fundamental elements that make up script programs. In the configuration of other parts of MCGS, expressions are also often used to establish connections between real-time databases and other objects. Entering and constructing expressions correctly is an important task in MCGS. 5. Operators: Arithmetic operators – ∧ (AND), * (exponentiation), / (division), \ (integer division); + (addition), – (subtraction); Mod (modulo operation). Logical operators – AND (logical AND), NOT (logical NOT), OR (logical OR), XOR (logical XOR). Comparison operators – > (greater than), >= (greater than or equal to), = (equal to), <= (less than or equal to), < (less than), <> (not equal to). 6. Operator precedence: From highest to lowest precedence, the operators are arranged as follows: ( ) has the highest precedence; followed by ∧, *, /, \, Mod; then +, –, <, >, <=, >=, =, <>; and finally NOT, AND, OR, XOR. II. Basic statements in script programs: Since MCGS script programs are used to control and process multi-path workflows, they only include a few of the simplest statements: assignment statements, conditional statements, exit statements, and comment statements. All script programs can be composed of these four types of statements. When it is necessary to include multiple statements in one program line, those statements must be separated by “:”. A program line can also be an empty line with no statements at all. In most cases, a program line contains only one statement; however, multiple statements can be placed on one line in an assignment line as needed. 1. Assignment statement: The format of an assignment statement is: data object = expression. An assignment statement is represented by the assignment operator (“=”), and its meaning is to assign the value resulting from the evaluation of the expression on the right side to the data object on the left side. To the left of the assignment operator must be a data object that can be read from and written to, such as switch-type data, numeric data, event-type data, and internal data objects that support write operations. Group objects, event-based data, read-only internal data objects, system internal functions, and constants cannot appear on the left side of the assignment operator, as write operations cannot be performed on these objects. The right side of the assignment operator is an expression, and the type of this expression must match the type of the data value on the left side; otherwise, the system will display an error message stating that the types of the assignment statement do not match. 2. Conditional Statements Conditional statements come in the following three forms: If 〖expression〗 Then 〖assignment statement or exit statement〗; If 〖expression〗 Then 〖statement〗 EndIf; If 〖expression〗 Then 〖statement〗 Else 〖statement〗 EndIf. The four keywords in conditional statements, “If”, “Then”, “Else”, and “EndIf”, are case-insensitive. If the spelling is incorrect, the checking program will display an error message. Conditional statements allow for multiple levels of nesting, meaning that new conditional statements can be included within existing ones. Conditional statements in MCGS script programs can have up to 8 levels of nesting, which enables the creation of control programs with multiple branching paths. “The expression in an “IF” statement is usually a logical expression, but it can also be an expression whose value is numerical. When the value of the expression is not 0, the condition is satisfied and the statements following “Then” are executed; otherwise, the condition is not satisfied, and the statements within that conditional block are not executed, with execution proceeding to the statements after that conditional block. Expressions with a character type cannot be used as expressions in an “IF” statement. 3. Exit statement: The exit statement is “E*t”; it is used to interrupt the execution of a script and stop processing the statements that follow it. Generally, an exit statement is used in conditional statements to stop and terminate the execution of a script under certain conditions. 4. Comment statements: Statements that begin with a single quote “’” are known as comment statements. In a script program, comment statements serve only to provide explanatory notes; during actual execution, the system does not process these comment statements in any way. III. Application scenarios of script programs and sample scripts Script programs have four application scenarios in the MCGS configuration software, namely: they are used in the \"Script Program\" component within the \"Operation Strategy\" ; Use it in the \"Script Program\" field of the \"Standard Button\" property settings in the window ; Use in \"Script Program\" within the \"Menu\" property settings ; It can also be used in the \"Startup Script\", \"Loop Script\", and \"Exit Script\" fields within the \"User Window\" property settings. In introductory materials, we have already become familiar with script programs within “operation strategies.” In this lesson, by using components such as checkboxes, timer functions, and string functions, we can apply script programs in MCGS configuration software in other three scenarios, thereby simplifying the configuration process and improving work efficiency. The result is shown below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image082.jpg 1. The specific steps for using script programs in “windows” are as follows: On the MCGS configuration software platform, click on “User Windows” to enter, then click the “New Window” button to create “Window 0”. Select “Window 0”, click the “Window Properties” button, and the “User Windows Properties” settings window will appear. After making the necessary settings, click the “OK” button to exit. As shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image084.jpg Double-click on “Script Program” to enter the “Animation Configuration” environment. Select the “Checkbox” from the toolbox, drag it to an appropriate location on the desktop, and double-click on the checkbox. This will bring up the “Checkbox Properties” dialog box. Choose “Other” from the “Option Type” dropdown menu, then click the “OK” button to exit, as shown in the following image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image086.jpg Next, select “Label” three times from the toolbox and place them on the desktop; these labels will represent: Checkbox Demo Program, Name, and Checkbox Selection Output. Use the selection box to choose the output attributes as shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image088.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image090.jpg. From the “Toolbox”, click on the “Common Icons” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image092.jpg icon; this will bring up the “Common Icons” menu. Select the “Concave Plane” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image094.jpg icon and the “Convex Plane” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image096.jpg icon, then place them in an appropriate location on the desktop. Use the “Bring to Front” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image098.jpg, “Send to Back” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image100.jpg, “Bring Up One Level” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image102.jpg, and “Bring Down One Level” file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image104.jpg options to create a 3D effect, as shown in the figure above. On the MCGS configuration software development platform, click on “User Window” and select the “Script Program” window. Then click the “Window Properties” button; this will bring up the “User Window Properties Settings” dialog box. Set the values as shown in the following images: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image106.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image108.jpg 2. Demonstration of counter operations in script programs using “Standard Buttons”. Timer numbers: The sequence numbers of system timers range from 1 to 255; the MCGS system includes 255 such system timers. Taking Counter 1 as an example, we need to use buttons to start and stop Counter 1, reset it, and set a maximum value for it. For specific applications of the function, see the “Online Help”. The specific steps are as follows: On the MCGS configuration software development platform, click on “User Window”, then double-click on “Script Program” to enter the “Animation Configuration” mode. Select the “Label” element 5 times from the “Toolbox” and place them in the positions indicated in the schematic, namely: demonstration of the operation of Counter 1, the count value of Counter 1, the display value of Counter 1, the operating status of Counter 1, and the maximum value of Counter 1. Select the “Label” element 3 times from the “Toolbox” and place them in the desired positions to serve as displays for “1st Counter Count”, “1st Counter Display”, and “1st Counter Status Display” during operation. Select the “Input Box” element from the “Toolbox” to allow input of the maximum value for the “1st Counter” during operation; the property settings are as follows: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image110.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image112.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image114.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image116.jpg We use buttons to control the start, stop, reset, and maximum value setting of the “1st Counter”. Specifically as follows: Select the “Standard Button” four times from the “Toolbox” and drag them to appropriate locations on the desktop; the corresponding property settings are as follows: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image118.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image120.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image122.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image124.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image126.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image128.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image130.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image132.jpg. String operations are often used in practical applications; for example, when working with the “V data memory” in Siemens’ 200 series PLCs. Enter a number between 0 and 9999. First, convert this number to a string; if it has fewer than four digits, pad the beginning with ‘0’s. Then break down the string, convert it to the corresponding ASCII code, and represent it in hexadecimal form. The specific steps are as follows: On the MCGS configuration software development platform, click on “User Window”, then double-click on “Script Program” to enter the “Animation Configuration” mode. Select the “Label” element three times from the “Toolbox” and place them in the positions indicated in the schematic, respectively for: string operation demonstration, inputting values, and displaying strings. Next, select the \"Input Box\" from the \"Toolbox\" and place it after \"Enter Value\"; then select the \"Label\" from the \"Toolbox\" and place it after \"String Display\" to show the string. Set them as shown below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image134.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image136.jpg Select the \"Standard Button\" three times from the \"Toolbox\" and drag them to appropriate locations on the desktop; as shown in the illustration, the button names are: Convert number to string, Split string into individual characters, and Convert character to ASCII code displayed in hexadecimal format. The attribute settings are as follows: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image138.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image140.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image142.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image144.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image146.jpg, file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image148.jpg. Select the “Tag” element from the “Toolbox” and drag it to an appropriate location on the desktop; then use the “Copy” button in the “Toolbar” to copy seven instances of it, so that they can be used to display the individual characters along with their hexadecimal values converted from ASCII codes. It can be processed using the file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image149.gif tool in the \"Edit Bar\". The attribute settings are as follows: for the String Split 2, String Split 3, and String Split 4 attributes, all that needs to be done is to replace \"String Split 1\" in the \"Expression\" field under \"Display Output\" with the corresponding \"String Split 2\", \"String Split 3\", or \"String Split 4\"” ; Among them: The settings for the attributes Data Display 2, Data Display 3, and Data Display 4 require simply changing \"Data Display 1\" in the \"Expression\" field under \"Display Output\" to the corresponding values of \"Data Display 2\", \"Data Display 3\", and \"Data Display 4\". file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image151.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image153.jpg 3. Application of script programs in menus On the MCGS configuration software development platform, click on the “Main Control Window” to enter menu configuration. In the “Toolbar”, click “Add Menu Item” to create a menu item named “Operation 0”. Double-click on this “Operation 0” menu to open the “Menu Property Settings” dialog box. Set the values as shown in the figure below: In the “Script Program” field, enter the following code: NumberInput=689 ‘Set initial value Maximum value for Timer 1=60 ‘Set initial value !TimerStop(1) ‘Stop Timer 1 from working !TimerReset(1,0) ‘Reset Timer 1 !TimerSetLimit(1,Maximum value for Timer 1,0) ‘Set the upper limit for Timer 1 to 60; it will restart running once it reaches 60. file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image155.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image157.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image159.jpg Press “F5” to enter the execution environment. Click on the “Script Program” menu to open the script program window, then click the “Start Counter 1” button to start Timer 1 ; Click the “Convert value to string” button, the “Break string into individual characters” button, and the “Convert character to ASCII code and display in hexadecimal” button, and the result will be as shown in: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image161.jpg Lecture 5: MCGS Data Post-Processing and Reporting I. Data Post-Processing In MCGS, data post-processing essentially involves working with historical databases. The historical databases stored by MCGS represent a collection of raw data, and data post-processing entails performing various operations on this raw data (such as modification, deletion, addition, and querying). The purpose of data post-processing is to extract useful data and information from these raw data and present them in the form of data reports. In engineering applications, after storing the collected engineering physical quantities, it is necessary to perform operations on the database and conduct various statistics on the stored data in order to generate reports in different formats as required. The data storage browsing component, data extraction component, and historical table component provided by the MCGS configuration software enable the creation of various types of data reports. The data processing flow in MCGS configuration software is as follows: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image163.jpg As shown in the figure, data is input from acquisition devices and enters the real-time database through device drivers. The MCGS configuration software offers various ways to display real-time variables from this database, such as in the form of data and curves. Additionally, it is possible to modify the timing and method of data storage using a data storage controller, and various operations can be performed on the data stored on the hard drive. The MCGS data storage browsing component allows for the direct display, printing, querying, modification, deletion, addition of records, and statistics on the stored data. The MCGS data storage extraction component can retrieve the stored data at regular time intervals or using various statistical methods. It is possible to extract the data into variables within the MCGS real-time database, or to pull relevant data into other types of databases based on specific search criteria. By using the data storage and extraction components of MCGS in conjunction with its historical tables, it is possible to generate various types of reports commonly used in industrial control projects (such as standard daily, monthly, and annual reports, reports with variable record fields, and reports requiring specific queries). II. Creating complex reports by combining data extraction – We will explain this in detail through examples, as follows: 1. Create a new window: On the MCGS configuration software platform, click on “User Windows” to enter, then click the “Create New Window” button to generate “Window 0”. Select “Window 0” and click the “Window Properties” button; the “User Window Properties” settings window will appear. After making the necessary settings, click the “OK” button to exit. As shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image165.jpg Double-click on “Data Extraction” to enter the animation configuration; the final result is as shown in the following image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image167.jpg 2. To simulate the required data, 7 variables are created in the real-time database, namely: “Data 1”, “Data 2”, “Data 3”, “Data 4”, “Data 5”, “Data Group”, and “Storage Control”. “\"Data 1\", \"Data 2\", \"Data 3\", \"Data 4\", and \"Data 5\" are numerical variables; \"Storage Control\" is a switch-type variable; \"Data Group\" is a group object, whose attribute settings are as follows: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image169.jpg file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image171.jpg On the MCGS configuration software platform, click \"Run Strategy\", then double-click on \"Loop Strategy\" or select it, and click \"Strategy Configuration\" to enter the strategy configuration interface. Click the \"Add Policy Row\" file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image030.jpg icon on the toolbar to add a new policy row. Next, select “Script Program” from the “Strategy Toolbox” and drag it to the strategy row at file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image032.jpg. Click the left mouse button, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image034.jpg. Double-click the icon at file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image173.jpg, and the “Expression Condition” dialog box will appear, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image175.jpg. Double-click the icon at file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image036.jpg to enter the script program editing environment. Enter the following commands to carry out simulations: Data1 = Data1 + 1; Data2 = Data2 + 2; Data3 = Data3 + 3; Data4 = Data4 + 4; Data5 = Data5 + 5; !SaveData(DataGroup) – This command saves the values of the DataGroup object to the hard drive. If you’re not sure, refer to the online help. On the MCGS configuration software platform, click “Run Strategy” to enter the strategy configuration mode. Then click the “Create New Strategy” button on the right side. The “Select Strategy Type” window will appear; select “User Strategy”. This will create “Strategy 1”. Click the “Strategy Properties” button, and the “Strategy Properties Settings” window will appear, as shown in the image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image177.jpg. Double-click “Raw Data” to enter the strategy configuration mode. Click “Add New Strategy Row” on the toolbar, select “Save Data Browse” from the toolbox, and drag it to the strategy row at file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image032.jpg. Click the left mouse button to place it in place. Double-click on file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image179.jpg, and the “Save Data – Browse Component Properties Settings” dialog box will appear. Set the properties as shown in the figure below: On this property page, basic attributes of the component such as the window title, printing options, statistics methods, and printing settings can be configured, as illustrated in file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image181.jpg. Window Display Title: Specify the title that will be displayed in the window; this title will also serve as the default title for printing. Print property settings: Set the printing direction and automatic background printing mode. Statistical methods: Sum, maximum value, minimum value, average value, sample variance, and standard deviation are available for selecting in order to process the data. Allow data modification at runtime: When this option is selected, it is only within the MCGS operating environment that changes to the stored data are permitted; in the configuration environment, there are no restrictions on modifying data ; Count by page during printing: When this option is selected, each page printed will be counted according to the specified counting method. Data source: This property page is used to set the method by which this functional component retrieves data from storage. Users can choose among three methods to obtain the data, as shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image183.jpg The data table corresponding to the MCGS group objects: The data contained in MCGS’s data storage objects is used as the data for display and printing. Access database files: Read data objects from a specific table in the database specified by the user, to use as data for display and printing. ODBC database: Retrieves data objects from specified tables through the ODBC data interface, which are then used as data for display and printing. Display properties: This page specifies the way in which the functional component will be displayed when it is run in the operating environment, including the format in which tables and data are presented, as shown in the following image: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image185.jpg Data columns: Display the names of the field fields in the specified database table that have been opened. Header: Set the title for the table header when displaying data; by default, it is the same as the field name. Unit: Set the unit corresponding to the data column, which is displayed in the table header (valid only for numeric field types). Decimal places: Set the number of decimal places to be displayed for the data column (valid only for numeric field types). Time display format: Set the display format for the time data column. Function buttons: In addition, buttons such as move up, move down, delete, and reset can be used to modify the display format of the data table. Time conditions allow access to data within a specified time period by setting the properties on this page; it is also possible to specify the sorting order of such data, as shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image187.jpg Sorting column name: Select the column name and sorting order (ascending or descending) for the data that is to be displayed and printed ; Time column name: If the selected database contains a time column name (e.g., MCGS storage database), the data will be retrieved and displayed based on the selected time column name and the specified time range. To implement sorting functionality or query data records by time, it is necessary to set a time column name. Time points for dividing a day: In engineering, using 0:00 as the boundary point of a day is not always appropriate. Therefore, to facilitate users, we can set specific time points within a fixed period that mark the division of a day. For example: 0:00 means from 00:00:00 to 23:59:59 every day ; At 6:00, it runs from 06:00:00 every day to 05:59:59 of the following day. Select time range: Choose “All saved data”, a specified time range, or the time range provided by the connected MCGS variables. To obtain data segments for display and printing that meet the user’s requirements, numerical conditions can be used. The attributes on this property page allow you to specify such numerical conditions for selecting data from databases or data objects; a numerical condition refers to a set of records whose corresponding fields satisfy certain conditions. As shown in the figure below: file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image189.jpg Column names: a list of fields from the data table, used to select the fields that will form part of the numerical conditions. Operation symbols: Set the comparison methods for data table fields, including >, >=, =, =, =, 100; the corresponding symbols are displayed. In this way, different colors will be displayed depending on the value while the system is running. 9. How to precisely adjust the size and position of labels or input fields? Answer: Use the four arrow keys on the keyboard to precisely adjust the position of a control, and use Shift + arrow keys to precisely adjust its size. 10. The animation’s movements change very slowly. Why? Answer: In the “Main Control Window – System Properties – System Parameters”, you can modify the flashing cycle and the animation refresh period; reducing these values appropriately can increase the speed of change. 11. Why is the “Compose Symbol” menu item grayed out? Answer: Many controls in the toolbox cannot be used to create icons, such as input fields and buttons. If the above situation occurs, it is because there are controls that cannot form symbols. 12. How to integrate third-party controls? Answer: Go to the menu “Tools – Policy Component Management”, then select “Install” and specify the path to the third-party component, and it will be automatically integrated. 13. How to use a historical curve to display the trend curves of different variables as required? Answer: Use the script according to the following syntax: “History Curve Window.ctrl History Curve.SetTrendVisible(curve_number, visibility)”. The curve number ranges from 1 to 16, and the visibility value is either 0 or 1. 14. How to jump directly to a certain time when displaying the historical curve? Answer: Use the SetXStart function (start time), with the time format being “yyyy-mm-dd hh:mm:ss”. 15. Can the historical curve be refreshed in real time? Answer: Yes, you can do this by selecting the “Auto-refresh at runtime” checkbox in the advanced properties of the timeline component, and setting the auto-refresh interval. 16. Is it possible to break down the graphs in the existing graph library and recombine them? Answer: Yes. After extracting the diagram from the diagram library, right-click and select the “Arrange” menu item; in the submenu that appears, you will find the options for decomposition symbols or decomposition units – simply choose the desired command. If the above menu items are not available, it means that the element is not composed of icons or units and cannot be broken down. 17. Can your work results be saved and utilized in other projects? Answer: Yes, select the elements you want to save, then choose \"Save Component\" from the toolbox. This will bring up the Object Component Management Library dialog box, where you can rename them, categorize them, and perform other necessary operations. It can be retrieved from the component library when configuring other projects. 18. How can I retain my image library when uninstalling MCGS and use it again? Answer: If the versions of MCGS that need to be installed and uninstalled are the same, or if the system component libraries are identical, then before uninstalling, copy the Library.lib file from the program directory in MCGS to another location for safekeeping. After installing the new version of MCGS, use this file to overwrite the corresponding file there. 19. How to achieve scheduled printing of historical reports? Answer: First, create a loop strategy and set the printing time in \"Execute at a specified fixed time\". In this strategy, add a “Data Extraction” component and a “Script” component, and include the following code: !setwindow(Historical Report Window, 2) ‘The window is opened and then hidden. !setwindow(Historical Report Window, 5) ‘Refresh the window. !setwindow(Historical Report Window, 4) ‘Print the window. !setwindow(Historical Report Window, 3) ‘Close the window. Then, create the Historical Report Window, add the Historical Report component, and select the data to be printed in order to enable scheduled printing. 20. How to create a horizontal report? Answer: In the database connection settings box of the historical table, uncheck the option “Display one data record per table row (horizontally fill records)” ; 21. There are too many records to display on one page. What should I do? Answer: On the “Database Connection” page of the historical reports, select “Display multiple pages of records”. 22. What should be done if the number of decimal places in the data shown in the reports varies? Answer: When the columns of the connected data table are numerical, formatted strings can be used to standardize the data format. The formatted string should be written in the style of: “Number 1 | Number 2”. Here, “digit 1” refers to the number of decimal places the output value should have, while “digit 2” refers to the number of spaces that should follow the output string; these two digits are separated by the symbol “|”. For example, “3 | 2” indicates that the output value should have three decimal places and two additional spaces. 23. How to assign the result of table cell calculations to a variable? Answer: Select a table cell, then choose the “Cell Connection” command. The “Data Cell Attribute Settings” page will appear; check the box labeled “Output table cell to variable”. Enter the variable name in the input field below, or select a variable from the real-time database. 24. Can the content of the table be modified before printing? Answer: The data in the free form cannot be modified ; The data in historical tables can be modified. To activate a historical table, right-click and select “Cell Connection”, then choose “Table cells are editable”. 25. Do the 4 built-in variables in the system count as points? Answer: It doesn’t count. The 4 built-in variables of the system are: InputETime, InputSTime, InputUser1, InputUser2. 26. Can variable names be in Chinese? Answer: Variable names can be either in Chinese or in English. 27. What is the use of grouping objects? Answer: It is used to store a collection of multiple variables with the same storage attributes, and its internal members can include various other types of variables. Group objects are generally used as data sources for creating reports and processing data. Once variables are added to group objects, it is sufficient to process the groups rather than each individual object, which not only saves a lot of time but also facilitates management. 28. How can I know how many points have been used? Answer: Use the “Check Usage Count” command in the “Tools” menu. 29. What should I do if a variable has been used after it was defined and cannot be deleted? Answer: First, use the “Check Usage Count” command in the “Tools” menu to check the usage of variables, and then you can delete those that are not being used. If a variable cannot be deleted, it means it is in use and cannot be removed. 30. Where is the historical database? Answer: In the property settings of the main control window, there is an option for storage parameters; here you can select the location where the database will be saved. Generally, when a new project is created, there is a default database location specified. For example, if the project is located at D:\MCGS\Work\Water Level Control System.MDB, the default database file name will be: D:\MCGS\Work\Water Level Control SystemD.MDB. 31. What type is a historical database? Can it be operated? Answer: The historical database is an Access database or an ODBC database, and it can be modified using the appropriate software. 32. How to print alarm information in real time? Answer: The storage of alarm information and its real-time printing are managed by MCGS’ real-time database. However, during configuration, these settings must be made on the “Storage Properties” page of the data object’s properties sheet; the options “Automatically save generated alarm information” and “Automatically print generated alarm information” should be selected. Otherwise, the system will neither save nor print the alarm information in real time. 33. Why can’t the alarm information be saved? Answer: It must be that during the settings on the \"Storage Properties\" page of the data object’s properties page, the option \"Automatically save generated alarm information\" was not selected. 34. How to convert a decimal number to a hexadecimal number? Answer: First, use the string manipulation function “!I2Hex(s)” from the system’s internal functions to convert the value into a hexadecimal string, and then use “!lVal(str)” to convert that string into a long integer value. For example ; !:I2Hex (17) =“11” !lVal(“11”)=11. 35. How to round off data with decimal places? Answer: Set the number of decimal places on the \"Basic Properties\" page of the data object’s property sheet. 36. How to compare whether two strings are identical? Answer: It can be used! StrComp(str1, str2) is used to compare whether the character data objects str1 and str2 are equal; a return value of 0 indicates equality, while any other value indicates inequality. Ignore case-sensitive characters. For example: !StrComp("ABC", "abc") = 0. 37 How to operate disk files? Answer: The internal functions of the MCGS system provide some file operation functions; for example, the !FileAppend(strTarget, strSource) function adds the contents of file strSource to the end of file strTarget, thereby merging the two files into one. For the specific content and usage of the function, please refer to the online help. 38. How to perform time calculations? Answer: Some time calculation functions are provided in MCGS’s internal functions to perform operations on events. For example: The !TimeStr2I(strTime) function converts a string representing time (YYYY/MM/DDHH:MM:SS) into a time value ; !TimeStr2I(“2001/1/1 3:15:28”) converts the string representing a time, “2001/1/1 3:15:28”, into a binary time value. For the specific content and usage of the function, please refer to the online help. 39. After the data is extracted, why is only “MCGS_Time” available and not the required data? Answer: On the last attribute page for data extraction, namely \"Extraction Method\", the corresponding name of the field after extraction was not filled in. 40. If you want to use data extraction to send the statistical results to a variable, how do you do that? Answer: On the attribute page for data extraction, under “Data Output”, select “Output to variable”. 41. How can one determine whether communication is normal? Answer: It is normal if the communication status bit is 0; a value other than 0 indicates that communication was not successful. 42. Can the device communication be freely controlled by the user? Answer: Yes, MCGS provides the !SetDevice (device name, parameters, command string) function; by using different values for the parameters, it is possible to perform functions such as starting, stopping, and monitoring. 43. What does device command mean? What is its use? Answer: Device commands are a series of custom commands sent to a device, which can be used to perform certain special functions. In MCGS, parameters that are read and written frequently are implemented through channel connections (such as PV), while access to less frequently used parameters is carried out via device commands (such as P, I, D), thereby greatly improving the effective utilization of the serial port. 44. Can a physical device be accessed using multiple drivers? Answer: Yes, access between multiple drivers is independent of each other. 45. Can multiple different devices be connected to one serial port? Answer: Yes, but the serial communication parameters of these devices, such as the communication baud rate, data bits, stop bits, and parity bits, must be exactly the same. 46. What if the device you developed supports the MODBUS protocol, but there is no device driver available in MCGS that meets your needs? Answer: MCGS provides standard MODBUS protocol devices that can be used with any device that supports the standard MODBUS protocol. 47. How to deal with abnormal operation of the acquisition board under NT? Answer: First, verify whether the hardware connection is proper and whether the device address is correct ; Then, for cards with ISA slots, check the Control Panel -> Devices -> to see if McgsPort is running. 48. When using Advantech 4000 and 5000 series modules, how do I set the module parameters? Answer: MCGS provides setup tools. Similar to the device configuration for a single module, add the setup tool under the serial port parent device, and then search for and modify the module parameters. 49. How to create help files for a project? Answer: The “HyperText” animation component can be used to load RTF files (Rich Text Files, which are created using WORD) as help files for the project. 50. Can network communication transmit both real-time data and historical data simultaneously? Answer: Yes ; Using the “Network Data Synchronization” and “Network Database Synchronization” devices, real-time data and historical data can be transmitted simultaneously. 51. Can MODEM communication be achieved if the caller or the called party is an extension? How to dial an extension number? Answer: Yes ; The specific method is to modify the phone number to “Phone Number” + “,” + “Extension Number”, with the latter part in between ; The purpose of a comma is to create a 3-second pause; one or more commas can be used, depending on the situation. 52. What should I do if I use a MODEM to call another computer and the other party never picks up the phone? Answer: Use the “MODEM Setup Tool” provided by MCGS to configure the MODEM as a remote MODEM. 53. Is the WWW version of IE the only browser? Answer: No, any software that supports OLE, such as IE, NETSCAPE, WORD, VC, VB, etc., can be used as a browser. 54. What software needs to be installed on a WWW client? Answer: Due to the use of a thin client mechanism, no software needs to be installed. However, the MCGSVIEW browsing control will be downloaded automatically on the first visit. 55. Can WWW only be used in corporate local area networks? Answer: No, it can be applied to Internet/Intranet. 56. The grid lines of a curve or table can only be displayed in part, but they can still be printed. Why is that? Answer: It is mainly due to problems with the graphics card driver installation; the solution is to download and install an updated driver. 57. Can the user window be printed in the configuration environment? Answer: Yes, you can use the menu “File – Print”. 58. Why aren’t Microsoft’s MSCOM controls used for serial communication in advanced development? Answer: MCGS uses interface-free serial communication, so controls cannot be used ; At the same time, MCGS uses underlying implementation code written in VC for serial communication, ensuring absolute reliability. 59. Why is it necessary to install SP3 when installing MCGS under WINDOWS NT40? Answer: SP3 is a patch package for NT40 that fixes some early errors in NT, and MCGS is built on top of SP3. 60. How to enable automatic execution of an MCGS project at startup? Shut down the computer automatically when exiting the MCGS project? Answer: Assume that your MCGS system is installed in the D:\MCGS directory, and the project file is located at D:\MCGS\Work\Test.MCG. For Windows 95 and 98: Open the SYSTEM.INI file located in the system directory of Windows 95 or 98, and change the value of SHELL=EXPLORER.EXE to SHELL=D:\MCGS\Program\MCGSRUN.EXE D:\MCGS\Work\Test.MCG. In this way, Windows will automatically enter the MCGS operating environment. Windows NT: Set the NT Administrator password to 123 (it cannot be empty). Open the “Start” menu, click “Run (R)”, type REGEDIT and press Enter to open the Registry Editor. Locate the key “My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon”. Change the value of Userinit= userinit,nddeagnt.exe to Userinit=D:\MCGS\Program\MCGSRUN.EXE D:\MCGS\Work\Test.MCG,nddeagnt.exe. Then right-click on the items on the right side of the Registry Editor and create two new string values, naming them AutoAdminLogon=1 and DefaultPassword=123. This way, Windows NT will automatically enter the MCGS operating environment.