Device Communications Subroutines in the Enabler Sample

The CIMPLICITY Device Communications Toolkit API provides a customizable interface between CIMPLICITY software and device communications.

Following is a sample of how the user-customized subroutines fit into the overall execution of the enabler.

The order provided here represents a very high-level description of operation and includes only those details believed relevant to customizing an enabler.

INITIALIZATION

Setup internal data structures

  READ process configuration data for enabler

  READ port configuration data for enabler

  CALL user_init()

  ...

  CALL user_open_port()

  CALL user_protocol_info();

  ...

  FOREACH CIMPLICITY DEVICE related to this ENABLER

     READ CIMPLICITY configuration data for device

     CALL user_device_info()

     READ point configuration data for device

     IF supported.model_req == TOOLKIT_YES

       CALL user_cpu_model()

     ENDIF

     FOREACH DEVICE_POINT

       CALL user_valid_point()

     ENDFOR

     IF supported.det_dev_status == TOOLKIT_YES

       CALL user_device_okay()

     ENDIF

  ENDFOR

  ...

  COMPLETE INITIALIZATION BY ESTABLISHING COMMUNICATIONS

  WITH INTERESTED CIMPLICITY SUBSYSTEMS

  ...

  WHEN

     UNSOLICITED_DATA_RECEIVED:

        IF support.unsolic_req == TOOLKIT_YES

           IF user_accept_unsolicited_data() returns TRUE

              CALL user_process_unsolicited_data()

           ENDIF

        ENDIF

     TIME_TO_SCAN_POINT_VALUES:

        IF support.read_req == TOOLKIT_YES

           SETUP parameters for read

           CALL user_read_data()

           CALL user_cvt_data_from_device()

        ENDIF

     SET_POINT:

        IF support.write_req == TOOLKIT_YES

           SETUP parameters for write

           CALL user_cvt_data_to_device()

           CALL user_write_data()

        ENDIF

     WRITE_POINT_QUALITY:

        IF support.unsolicited_quality_data == TOOLKIT_YES

           CALL user_write_point_quality()

        ENDIF

     READ_ADDRESS:

        IF ((support.read_addr_req == TOOLKIT_YES) &&

           (support.read_req == TOOLKIT_YES))

           CALL user_valid_point()

           IF valid

              CALL user_read_data()

              CALL user_cvt_data_from_device()

           ENDIF

        ENDIF

     WRITE_ADDRESS:

        IF ((support.write_addr_req == TOOLKIT_YES) &&

            (support.write_req == TOOLKIT_YES))

           CALL user_valid_point()

           IF valid

              CALL user_cvt_data_to_device()

              CALL user_write_data()

        ENDIF

        ENDIF

     DEMAND_STATUS_UPDATE:

        IF (point is no longer in demand)

           CALL user_on_demand_response()

        ELSE

           CALL user_on_demand_response()

           IF ((support.read_addr_req == TOOLKIT_YES) &&

               (support.read_req == TOOLKIT_YES))

              CALL user_valid_point()

              IF valid

                 CALL user_read_data()

                 CALL user_cvt_data_from_device()

              ENDIF

           ENDIF

        ENDIF

     TIME_TO_RETRY_FAILED_DEVICES:

        FOREACH uninitialized device

           CALL user_device_info()

           IF supported.model_req == TOOLKIT_YES

              CALL user_cpu_model()

           ENDIF

           FOREACH DEVICE_POINT

              CALL user_valid_point()

           ENDFOR

           IF supported.det_dev_status == TOOLKIT_YES

              CALL user_device_okay()

           ENDIF

        ENDFOR

     NEW_POINT_DYNAMICALLY_CONFIGURED:

        CALL user_valid_point()

        IF poll-once point

           CALL user_read_data()

     CHECK_DEVICE_STATUS:

        IF ((support.host_redundancy == TOOLKIT_YES) &&
           (currently secondary node))

           CALL user_heartbeat_device

        ENDIF

     SHUTDOWN:

        Cleanup

        CALL user_term()

     USER_EVENT_1:

        CALL user_proc_event_1()

     USER_EVENT_2:

        CALL user_proc_event_2()

     USER_EVENT_3:

        CALL user_proc_event_3()

     USER_EVENT_4:

        CALL user_proc_event_4()

     USER_EVENT_5:

        CALL user_proc_event_5()

     USER_EVENT_6:

        CALL user_proc_event_6()

     USER_EVENT_7:

        CALL user_proc_event_7()

     USER_EVENT_8:

        CALL user_proc_event_8()

     USER_EVENT_9:

        CALL user_proc_event_9()

     USER_EVENT_10:

        CALL user_proc_event_10()

  END WHEN

More information

About the Device Communications Toolkit.