CrossBeltSorter: SubscribeOnBeltBlocking
Called to subscribe the belt blocking event, if the belt block/detect at given distance, the callback function gets execute
Function
integer blockHandle SubscribeOnBeltBlocking(callback: function, distance: double);
Parameters
Name | Type | Description |
---|---|---|
callback | Integer | The callback function which need to execute when belt block. |
distance | Integer | The distance that belt get block/detect. The distance should measure from sorter initial point. |
Return Value
integer blockhandle. The blockhandle can be use to unsubscribe blocking events.
Callback Signature
void xxxxxxxxxxxxxxxxx(sender: object, beltIndex: integer, product: Product)
Name | Type | Description |
---|---|---|
sender | Object | The object associated with the subscribe blocking event. |
beltIndex | Integer | The index of the belt which get block/detect. |
product | Product | The product object if the belt carried it or can be null (if empty). |
Example
var cbs;
var handle1;
var handle2;
var count = 0;
var count1 = 0;
function OnSimulationStart() {
cbs = GetComponentByNameAndType("CrossBeltSorter1", "Cross Belt Sorter");
handle1 = cbs.SubscribeOnBeltBlocking(OnBeltBlockingCallBack_Position1, 5.6);
handle2 = cbs.SubscribeOnBeltUnblocking(OnBeltUnblockingCallBack_Position1, 5.6);
}
function OnBeltBlockingCallBack_Position1(sender, beltIndex, product) {
if(product != null) count++;
if(count == 8) UnsubscribeBlocking(handle1);
}
function OnBeltUnblockingCallBack_Position1(sender, beltIndex, product) {
if(product != null) count1++;
if(count1 == 12) UnsubscribeUnblocking(handle2);
}
function UnsubscribeBlocking(handle) {
cbs.UnsubscribeOnBeltBlocking(handle);
}
function UnsubscribeUnblocking(handle) {
cbs.UnsubscribeOnBeltUnblocking(handle);
}