The robots class is used to synchronize and revoke orders, or synchronize the robot stocks. More...
Public Types | |
| enum | OrderSyncMode { SyncAll = 0, SyncNew = 1, SyncUpdate = 2 } |
| Order items synchronize mode. More... | |
| enum | OrderType { Trips = 0, Rows = 1, Columns = 2, Items = 3 } |
| Type of the keys to process. More... | |
Public Member Functions | |
| void | addRobotsToTrip (Number aOrdertrip) |
| Add robot status records for all zones having a robot to a trip. | |
| void | lockRobot (Number aZone) |
| Lock the zone for exclusive robot access. | |
| void | revokeOrders (Number aZone, OrderType aOrderType, Array aKeys) |
| Revoke orders from the robot. | |
| Robots (Datastore aDatastore, String aProgram) | |
| Constructor for a new Robots object. | |
| void | syncOrders (Number aZone, OrderType aOrderType, Array aKeys, OrderSyncMode aSyncMode) |
| Synchronize orders to the robot. | |
| void | syncStock (Number aZone) |
| Import all robot stocks into the BPS stock. | |
| void | unlockRobot (Number aZone) |
| Unlock the zone, in case it was locked by the current actor. | |
Properties | |
| Boolean | anyRobots |
| True if there are any robots. | |
| Array | zones |
| List of zone keys with active robots. | |
The robots class is used to synchronize and revoke orders, or synchronize the robot stocks.
Typically a "New" sync would be done after importing new orders.
Example:
importExtension('bps'); bps.log('Connect to database'); var ds = new bps.Datastore; ds.connection = 'os_zmc'; ds.username = 'os_zmc1234'; ds.password = 'os_zmc5678'; if (!ds.loadConnection()) throw Error("Invalid connection.\nKnown connections are: "+bps.Datastore.connections); ds.connect(); ds.purgeActors(); ds.checkin(); bps.log('Import orders'); var newItems = new Array(); var utl = new bps.OrderUtils(ds); while (!allImported) { // create tripKey, tripDate etc. from import source var item = utl.makeOrderItem({ ordertrips_trip: tripKey, ordertrips_date: tripDate, orderrows_partner: partnerKey, ordercols_article: articleKey, orderitems_ordered: ordered }); newItems[newItems.length] = item; } bps.log('Synchronize new items with robots'); var robots = new bps.Robots(ds,'Import'); for (var r = 0; r < robots.zones.length; ++r) { robots.syncOrders( robots.zones[r], bps.Robots.Items, newItems, bps.Robots.SyncNew ); } bps.log('Disconnect from database'); ds.checkout(); ds.disconnect();
Order items synchronize mode.
Basic condition for all sync operations is that the order trip status must be active.
Constructor for a new Robots object.
| [in] | aDatastore | The datastore object to use |
| [in] | aProgram | Name of the program, to be used in license tokens. |
| void bps::Robots::addRobotsToTrip | ( | Number | aOrdertrip | ) |
Add robot status records for all zones having a robot to a trip.
| [in] | aOrdertrip | The key of the order trip to send. |
| Error | thrown on database errors. |
| void bps::Robots::lockRobot | ( | Number | aZone | ) |
Lock the zone for exclusive robot access.
| [in] | aZone | Key of the zone. |
| Error | thrown on SQL errors. |
| void bps::Robots::revokeOrders | ( | Number | aZone, |
| OrderType | aOrderType, | ||
| Array | aKeys | ||
| ) |
Revoke orders from the robot.
The method tries to revoke as many items as possible as long as no fatal error or cancel happens, and only throws an exception about the robot unable to revoke certain items at the end.
In case of aborting (fatal error) in a critical communication phase, the status BPS knows about the robot may be inaccurate and have to be cleared manually by the user. The message of the thrown exception will in such a case include information about that fact.
| [in] | aZone | Key of the zone. |
| [in] | aOrderType | Type of the records addressed by aKeys. |
| [in] | aKeys | List of keys to process. |
| Error | thrown when revoking the trip failed or was aborted. |
| void bps::Robots::syncOrders | ( | Number | aZone, |
| OrderType | aOrderType, | ||
| Array | aKeys, | ||
| OrderSyncMode | aSyncMode | ||
| ) |
Synchronize orders to the robot.
The method tries to synchronize as many items as possible as long as no fatal error or abort happens, and only throws an exception about rejects at the end.
In case of aborting (fatal error) in a critical communication phase, the status BPS knows about the robot may be inaccurate and have to be cleared manually by the user. The message of the thrown exception will in such a case include information about that fact.
| [in] | aZone | Key of the zone. |
| [in] | aOrderType | Type of the records addressed by aKeys. |
| [in] | aKeys | List of keys to process. |
| [in] | aSyncMode | Synchronizing mode. |
| Error | thrown when sending the trip failed or was aborted. |
| void bps::Robots::syncStock | ( | Number | aZone | ) |
Import all robot stocks into the BPS stock.
| [in] | aZone | Key of the zone. |
| Error | thrown when querying the stock levels failed or was aborted. |
| void bps::Robots::unlockRobot | ( | Number | aZone | ) |
Unlock the zone, in case it was locked by the current actor.
| [in] | aZone | Key of the zone. |
| Error | thrown on SQL errors. |