SGCom is designed to be resilient to various forms of outages. When it starts, it must connect to the metering central to get the configuration (without which it will not perform any action), but then it can work even if it loses contact with the metering central for some time. It is robust even if it fails to collect data, which it reports to the metering central and provides mechanisms to recover the data later. The life cycle is illustrated in the following figure and can also be described in the following steps.


 

Figure 3 - Illustration of the life cycle

  1. Starting the application, processing the command line parameters, which, among other things, contain the address for connecting to the D2000 kernel, login data, and the address of the so-called "point of first contact".
  2. Performing maintenance on the DataStorage module:
    • Deleting records older than 90 days. The task repeats every 24 hours.
    • Removing the transaction number tag from all records (details in step 7).
  3. Connection to the D2000 kernel of the metering central. SGCom tries to get a D2Japi Session, which will be represented in DODM by an object with the name in the form SGCOM1.SGC. If unsuccessful, the connection is retried every 30 seconds.
  4. Signing in to the "point of first contact" The address of the object is defined by the -f command-line parameter, which is an instance of an object of type D2000 Event that implements the I.SGC_FirstContactServer interface. It signs in by calling RPC SignIn with the _name parameter value set to the process name (from the command line). RPC is asynchronous and establishes an application-defined conversation that ensures that either SGCom or metering central knows when its partner crashes.
  5. The metering central responds to the establishment of the first contact by sending a new configuration to SGCom, or changes the existing one. The D2000 Event that controls sending the configuration must implement the I.SGC_Configurator interface, SGCom implements the I.SGC_Configurable interface for reception.
    1. Configuration transfer is transactional. All changes are either OK and accepted as a whole, or all are rejected and the configuration is left in its original state. The sequence of steps is as follows:
      1. Open Transaction: I.SGC_Configurable^OpenTransaction
      2. Submit changes: I.SGC_Configurable^Set* and Delete*.
    2. Commands must be entered in such a sequence that the referential integrity of the configuration database is not violated at any time.
      1. Commit of the transaction: I.SGC_Configurable^Commit
      2. Confirmation of acceptance of changes I.SGC_Configurator^OnTransactionAccepted, or rejection of changes I.SGC_Configurator^OnTransactionDenied with a list of errors in the parameter.
    3. Alternatively, the transaction can be rolled back from the metering central by calling I.SGC_Configurable^Rollback, which SGCom will confirm with I.SGC_Configurator^OnTransactionRolledBack. The transaction is automatically canceled also if the application-defined conversation is interrupted.
  6. According to the current SGCom configuration, SGCom sets its task schedule - for each PeriodicEvent entity, it creates a separate record and schedules its execution.
  7. When the time point for which a periodic event is scheduled occurs, SGCom looks at the current configuration and starts performing all related tasks. In the TaskExecutor module, tasks for collecting and transferring data are inserted into the appropriate queues, which the TaskExecutor then executes. The execution of tasks that do not compete with each other is parallel. (Note: two tasks that are executed on the same logical device and also tasks that serve logical devices connected by the same communication line compete with each other. Data collection and transmission do not compete with each other.)
    Data collection of each variable, whether successful or unsuccessful, ends with the result being recorded in the DataStorage module. On successful collection it's a list of values with timestamps, on failure it's the error code and description, also timestamped.
    Values are transferred to the metering central by individual logical devices and individual quantities (DataPoint). Each transfer represents a separate transaction, and only when the central office confirms the successful transfer of values, the data is removed from DataStorage. The upload for one logical device and quantity consists of the following steps:
    1. Generation of a unique transaction ID.
    2. All records for a given logical device and quantity are identified by a transaction number. (If the previous transaction has not ended, only new records are marked.)
    3. The values and timestamps of tagged records are sent by calling I.SGC_DataCollector^OnDataCollected.
    4. After data processing, the transaction is terminated by calling I.SGC_DataProducer^OnDataAccepted.
    5. Records marked with the corresponding transaction number are deleted from DataStorage.
      (Note: RPC communication takes place as part of an application-defined conversation, so if the processing of transferred data fails for some reason, SGCom will learn about this fact and the transaction will be canceled. The data will remain in DataStorage until the next scheduled data transfer, and the transaction number will be removed.)
  8. At any time after sending the configuration, the metering central can send a command to perform an "immediate" task. Most often, the reading of archived data of measured variables is performed for the period for which data is missing in the central station, but also the setting of the exact time in the meters and others. Commands are controlled by pair interfaces I. SGC_ImmediateReadMasterSlave, I.SGC_SetRTCMasterSlave, I.SGC_ConsumerDisconnectMasterSlave, where the metering central implements the Master interface and SGCom implements the Slave. All commands take place in the mode of application-defined conversations but always consist of a simple exchange of command - notification of the result.
  9. If the SGCom loses connection with the metering central, it continues to perform the scheduled tasks as described in point 7. Data collection continues unchanged, all transmission attempts fail, and the collected data is therefore collected in DataStorage until the connection is restored and the data uploaded. After establishing a new connection, the execution continues with point 4.


TaskExecutor module

The TaskExecutor module is responsible for executing all tasks that result from the configuration as well as all "immediate" tasks. It uses a list of rules that determine which tasks can be executed in parallel. For tasks that cannot be executed in parallel (because they compete for access to the meters), it defines the order in which they are performed to maximize throughput. At the same time, these rules define time windows during which communication with some meters is not possible - after the connection is terminated, it is not possible to establish a new connection for a certain time.
These rules must be taken into account when creating the configuration, as well as the time it takes to establish a connection, execute each task, close the connection, and shut down the connection so that more tasks than can be serviced are not scheduled.
When operating meters, the performance of tasks is governed by the following rules:

  1. It is not possible to create two or more connections to a single logical device at the same time.
  2. It is not possible to create simultaneous connections to two logical devices that are connected by the same communication line (they share the same Connector entity in the configuration).
  3. If there is an active connection to a logical device, all tasks queued for that device must be executed before the connection is closed (for optimization reasons). Tasks are selected from the queue using a "first-came-first-served" policy.
  4. After the last task from the queue is executed, the connection to the logical device remains active for 10 seconds. The length of waiting for a new task can be adjusted with the command line parameter -n. If a new task is added to the queue during this time interval, it is also executed and the connection is kept established for another 10 seconds. The connection is closed only when no new task is added. (In order to efficiently serve fast-repeating tasks.)
  5. After canceling the connection, it is not possible to create a new connection to any of the logical devices that are connected by the used communication line for 20 seconds. The length of the protection interval can be changed from the command line with the parameter -s. (Because the connection would still be rejected and would last longer until the connection could be established again.)
  6. After the 20-second guard interval expires, the next logical device waiting in the queue is served.
  7. If an attempt to establish a connection with a logical device is unsuccessful 3 times in a row, it is considered disconnected - HardError state - and a connection cannot be established with it for the next 5 minutes. The number of attempts can be changed with the command line parameter -r. The duration of the HardError state can be modified with the command-line parameter -d. All jobs in the queue that should have been executed on this device are canceled, as well as all new jobs for the duration of the HardError state. After this period, it is possible to try to connect to the device again.
  8. All tasks that do not compete with each other can be executed in parallel by the threads of the respective ThreadPool. The maximum number of threads in the ThreadPool is 512. The maximum number of threads can be adjusted with the command line parameter -t, but it changes dynamically according to current needs.




0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .