+ // Configuable dummy/blank mode (all dispenses succeed)
+ // TODO: Find a better way of handling missing/invalid options
+ if( Config_GetValueCount("coke_dummy_mode") > 0 )
+ {
+ gbCoke_DummyMode = Config_GetValue_Bool("coke_dummy_mode", 0);
+ if(gbCoke_DummyMode == -1) gbCoke_DummyMode = 0;
+ }
+
+ // Open modbus
+ if( !gbCoke_DummyMode )
+ {
+ Coke_int_ConnectToPLC();
+ }
+
+ return 0;
+}
+
+int Coke_CanDispense(int UNUSED(User), int Item)
+{
+ int slot;
+
+ // Check for 'dummy' mode
+ if( gbCoke_DummyMode )
+ return 0;
+
+ // Get slot
+ slot = Coke_int_GetSlotFromItem(Item, 0);
+ if(slot < 0) return -1;
+
+ return Coke_int_IsSlotEmpty(slot);
+}
+
+/**
+ * \brief Actually do a dispense from the coke machine
+ */
+int Coke_DoDispense(int UNUSED(User), int Item)
+{
+ int slot;
+ // Check for 'dummy' mode
+ if( gbCoke_DummyMode )
+ return 0;
+
+ // Get slot
+ slot = Coke_int_GetSlotFromItem(Item, 1);
+ if(slot < 0) return -1;