Building a Conveyor Belt Model in Papyrus-RT

I’m working on modeling a conveyor system using low cost hardware (lego bricks, IR Sensor, DC Motor and Raspberry Pi). I have already built the conveyor belt and now I need to model it using Papyrus-RT.

Papyrus-RT model must have Restrictions:

  1. The behavioural logic, in the form of C++ code snippets along Transition Effects and State Entry/Exit, should be kept short and simple. Restricted to use only the port related instructions and any direct attribute changes, but avoid any other functional code.
  2. Replace code blocks with the design elements wherever possible. For example, variable declarations to be handled with UML-RT attributes, if-else logic to be replaced with pseudo states and transitions with effect, and so on.
  3. Messages within user-defined Protocols are to be limited to carry at max one payload of integer type only. Comments about the domain set of this parameter should also be updated and must always include a non-functional ‘0’.
  4. Do not use payload directly for any computation, but always use a designated local attribute to read the incoming payload and then use this updated value.
  5. A single attribute should not be updated more than ones along one complete transition between two stable states.
  6. In case of port-replication, where the outgoing messages could be sent/broadcasted in any random order, separate controller threads to be used for each receiving capsule.
  7. For every integer type attribute, a pair of read-only integer attributes should be included to mark the domain max and min values.

Optional Restrictions:
8. Try to avoid functions specific to C++ libraries. This is because, the behaviour of any special C++ library used in code, needs to be manually abstracted into the nuXmv model for translation.
9. Use only port related functionalities or direct assignments in the state entry/exit actions.

This is what I have done so far:

  • DCMotorCapsule:  status of the conveyor (moving, stopped).
  • SensorCapsule: to track whether an item has been detected.
  • ControllerCapsule: manages the overall system status and stores the current state of each component for decision-making purposes.
  • Raspberry Pi Top Capsule: contains all capsules.

DCMotor Capsule
Variables:

  • conveyorStatus: Integer, tracks the status (0 for stopped, 1 for running).
    Protocols:
  • ConveyorControl: Single integer payload for commands like start (1), stop (0).
     
    Sensor Capsule:
    Variables:
  • sensorStatus: Integer attribute to track the sensor status. 0 for no item detected, 1 for item detected.
    Protocols:
  • DetectionProtocol: Single integer payload to communicate detection status (1 for item detected, 0 for not detected).
     
    Controller Capsule
    Variables:
  • systemStatus: An integer to represent the overall status of the system.
  • errorStatus: An integer for error codes (0 for no error, other values for specific errors).

Protocols:  

  • ControlProtocol: Uses an integer payload for control commands.
  • StatusProtocol: Uses an integer payload for status updates.

Ports:
Step-by-step:**

  • The IR sensor capsule detects an item and changes its sensorStatus to ‘1’.
  • The IR sensor sends a message via its DetectionOutput port using the DetectionProtocol.
  • Controller Receiving the Detection Hint:
  • The Controller capsule has a StatusInput port that is connected to the DetectionOutput port of the Sensor capsule.
  • When an item is detected, the Sensor sends an ItemDetected message with a payload of ‘1’ to the Controller.
  • The Controller’s StatusInput port has a trigger set up to listen for this ItemDetected message.
  • Controller to Conveyor Belt Communication:
  • Upon receiving the ItemDetected message, the Controller processes it and then sends a command to start the conveyor belt through the ControlOutput port of the Controller, which is connected to the ControlInput port of the DCMotorCapsule using the DCMotorCapsule protocol.
  • ‘1’ is sent to the DCMotorCapsule capsule, instructing it to start.
     
Code:
IR Sensor Capsule
 
class SensorCapsule {
public:
    // UML-RT Attributes (Variables)
    int sensorStatus;  // The sensor status: 0 for no item, 1 for item detected
 
    // Constructor
    SensorCapsule() : sensorStatus(0) {
        // Initialization of sensor capsule, sensor starts with no item detected
    }
 
    // This function is a placeholder for an actual sensor read operation.
    void detectItem() {
        int detected = readSensor(); // Reading sensor
        if (sensorStatus != detected) {
            sensorStatus = detected;  // Updating the sensor status
            sendDetectionStatus();   // Send the detection status if it has changed
        }
    }
 
private:
    // Read the sensor hardware to detect an item
    int readSensor() {
        //   sensor reading code
        // Return 1 if item is detected, 0 otherwise
    }
 
    // Send the detection status to the controller capsule
    void sendDetectionStatus() {
        // send msg via DetectionOutput port using the DetectionProtocol
    }
};
 
Code:
Controller Capsule
 
class ControllerCapsule {
public:
    ControllerCapsule();
    void handleDetectionMessage(int message);
    void commandConveyorBelt(int command);
};
 
 
void ControllerCapsule::handleDetectionMessage(int message) {
    // Simple if-statement to determine the command for the conveyor
    int command = (message == 1) ? 1 : 0; // 1 to start, 0 to stop
    commandConveyorBelt(command);
}
 
void ControllerCapsule::commandConveyorBelt(int command) {
    // send the command to the DCMotor Capsule
}
 
 
 
Code:
DCMotor Capsule
 
class DCMotor Capsule {
public:
    ConveyorBeltCapsule();
    void handleControlCommand(int command); // To handle incoming control commands
};
 
 
ConveyorBeltCapsule::ConveyorBeltCapsule() {}
 
void ConveyorBeltCapsule::handleControlCommand(int command) {
    // 1 for start, 0 for stop
    if (command == 1) {
        // Code to start the conveyor belt
        // maybe: setConveyorStatus(1); where setConveyorStatus is a function to start the belt
    } else if (command == 0) {
        // Code to stop the conveyor belt
    }
}
 
// Define the function that will interface with the hardware or the simulation API
void setConveyorStatus(int status) {
    //   hardware control logic
}

Papyrus Model

Can someone help fill in the rest of the code and help with the model in papyrus? I can’t find that much information online considering this is not so used and I’m not that good in C++.
Thanks!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật