Expansion of Asprova's functions through the COM interface

2011/10/04

COMインターフェイス

Commercial ERP and APS systems do not expose the source code, but instead expose the COM interface so that the functionality can be extended with Standard EXE files and plug-ins (DLLs).

Just like WordPress, the Asprova plug-ins do not work on their own, they need to be added to the main software to function.

The Asprova main unit has a hook for executing plugins at the timing of the event, and the plugin key, which is the access point for this event, corresponds to the do_action hook or the apply_filters hook of WordPress.

What is the COM interface?

Asprova has a mechanism for disclosing internal data and processing contents with COM (Component Object Model) and can be used to add functions through plug-ins (ActiveX DLL files: call functions from Asprova) and automation clients (Standard EXE files: It is possible to add functions through plug-ins (ActiveX DLL files: call functions from Asprova) and automation clients (Standard EXE files: access to Asprova from external programs).

The DLL files are located in the same folder as the Asprova EXE files and are automatically loaded into Asprova at startup.

Since the DLL file is registered as an internal command of Asprova, it is necessary to attach it to the user-defined menu to call the DLL file from Asprova, but in the case of EXE, it is necessary to specify the name of the project file and open it to get the active project (from DLL or EXE).

Location of DLLs

The DLLs should be located in the following places in terms of the EXE you are launching

  1. Place EXE and DLLs in the same directory.
  2. Make the current directory the DLL directory when you start EXE.
  3. Place the DLL in the system32 directory.
  4. Place the DLL in your Windows directory.
  5. Set the directory where the DLL is located in the Path environment variable.

Development environment reference settings (using Asprova libraries from within the plugin)

The reference settings are saved in a project file (.vbp file) in order to use the type library of the ActiveX object that does not have a GUI in the project, and the reference settings are saved in a project file (a .vbp file), and then the plug-in (DLL that compiled the project file) is used to create the Asprova Access the library.

The reference settings allow you to use the object's type when declaring a Dim variable or create an instance with the new operator.

  1. Asprova Project Class
    Dim project As aslib.ASBProject
  2. List of objects related to plugin keys used in extension plugin DLLs
    Dim ArgList As ASPArgList
  3. Item Class
    Dim item As ASBItem

When referring to the Asprova library from the plug-in, register the following two Asprova class libraries from the reference settings in the development environment.

  1. As 1.1 Type Library
  2. AsPlugInManager 1.0 Type Library

Organization of the plug-in project file

In the case of plug-ins, you need to register the function to be called from Asprova in the AutoRegistration method of the ASDefault class. It will be called automatically and implemented in the project object.

COMポート2

In the case of Standard EXE (automation client), you don't need the ASDefault class ("How to get Asprova object from DLL or EXE").

You register a plugin by passing 4 arguments to the AddASPlugIn method of the Asprova plugin manager (plugin registration function), but the contents of the arguments are as follows: "I am a project called Factory, and I have a class called Overtime and a class called AddOverTime method (entry function), so call it at the timing of the plug-in key KeyHookGeneric".

Mapping Hooks and Functions to Plug-in Keys (Access Points)

Asprova provides hooks to execute plugins for each event. The access point that represents each of these events is called a plug-in key. For example, KeyHookGeneric is used to "add a command", or in other words, to execute the plug-in by executing the command at the access point at the time the added command is to be activated.

Option Explicit
Public Function AutoRegistration(plugInManager As ASPPlugInManager, module As ASPModule) As Boolean
    'Set the comments for this module
    module.Comment = "APS Extended Functionality PlugIns (VB)"
    'Define a variable that holds a plugin object
    Dim plugIn As ASPPlugIn
    ' ---------------------------------------------------------------------------------------------
    'Call the plugin manager and register a new plugin. The name of the calling method is AddASPlugIn
    ' 第1Param:Plug-in display name
    ' 第2Param:ProgID that represents the module and class in which the plugin is implemented
    ' 第3Param:The entry function name of the plugin (call name)
    ' 第4Param:A key name that represents the context in which the plugin is used

    '(1)Overtime and weekend overtime are automatically calculated and set in the calendar table.
    Set plugIn = plugInManager.AddASPlugIn("Incorporate overtime into overtime and Saturday work", "Factory1.OverTime", "AddOverTime", ASPlugInKeyName.KeyHookGeneric)
    'You can add comments etc. to this plugin.

    plugIn.Comment = "Overtime is assigned to 2 hours of weekday overtime and 2 shifts of Saturday work."
    'Plugin call order (for when there are multiple plugins with the same plugin key)
    plugIn.Order = 1
    'True, indicating that the automatic registration was successful.
    AutoRegistration = True
End Function

When Asprova automatically loads the plug-ins at startup, it displays the "display name of the entry function" (the first argument when calling the plugin manager) in the internal command plug-ins.

We register the plug-in by calling the Asprova plug-in manager from within the plug-in and passing the four arguments.

COMポート3

Same concept as a COM port (communication port)

By the way, COM ports and COM interfaces are different from each other, but in terms of standards for external interfaces, COM ports and COM interfaces are the same.

Software and hardware have a standardized interface (port) for exchanging data with the outside world. For example, the ports on a POP and SMTP server and the port for connecting to a DB are both TCP/IP ports.

Standard PCs have PS/2 ports, USB ports and LAN ports (Ethernet ports) as interfaces for connecting peripherals such as keyboards.

In the case of software, the OS and other operating systems provide a standardized, unified way to send and receive data to and from external devices and communication networks, and the ports are used to identify the people with whom the software is communicating.

In Windows, to enable application software to access modems, printers, image scanners, etc. in a unified manner, a system called "COM port" with a unified input/output method is provided, and application software is able to identify the COM port to which the target device is connected. You can handle the input and output to the device in question by just knowing what port is used.

For example, when you connect a USB barcode, COM13 is assigned to it, but the COM13 port is just a virtual one because there are no 13 interfaces physically in the PC.

In network communication using TCP/IP, a "port number" between 0 and 65535 is used as an auxiliary address under the IP address of the communication device or individual computer.

This allows a single computer to provide multiple services and to communicate with multiple computers simultaneously. The term "port" is often used simply to refer to the TCP/IP port number.