Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Object development - check EtherCAT state of peripheral during command execution

    Object development - check EtherCAT state of peripheral during command execution

    maj9bj
    Long-established Member

    I would like to discuss how to corretly handle object command if peripheral is not ready because of missing EtherCAT connection.

    1. I have object containing command Start measurement.
    2. If the command is executed it calls StartMeas method of my peripheral.
    3. If EtherCAT connection is missing StartMeas is executed but it remains in step 0 waiting for some signal from hardware (e.g. CycleEnd = FALSE).

    How to handle the state EtherCAT does not work? I have few ideas, but I would like to know what is the best or standard solution. My ideas are:

    1. I can ask in object OnExecStart if the device is ready and throw en event for this state. I think I'd rather deal with it on the periphery side.
    2. I can put something at the begining of StartMeas peripheral method to ask for EtherCAT state. But how? IF (BusComm, DeviceReady ) from OpconEcSlave???
    2 REPLIES 2

    Bianca
    Community Moderator
    Community Moderator

    If your peripheral looses it's EtherCAT connection it goes into an error state (HasError = True). You can check if the peripheral has no error at the top of every command method. If the connection probelm is resolved bevor the command method is called there will be no problem.

    Example:

    // Check if peripheral has an error
    IF( HasError )
    THEN
      SetDeviceError( ObjectID := PeripheralConstants.OOID,
                                         Number  := PeripheralEvents.FLT_PERIPHERAL_ERROR,
                                         AddText := '',
                                         NativeErrCode := 0,
                                         EventStdFlags := 0 );
      CommandMethod := HAS_ERROR;
      RETURN;
    END_IF

    hbszjjw
    Established Member

    In my opinion,  you don't need any code to handler EtherCAT error, this is done by OpconBase, if EtherCAT state is not ok, all object will receive Cancel signal from OpconBase or by SafetyAddon, and your object will execute OnExecCancel, normally the unit object would call Reset method of peipheral object, you only need put some code in Reset method of peipheral object to such as reset _step variables.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist