#
# OpenDispense2 Server config file
#
-daemonise no
-server_port 11020
+daemonise yes
+server_port 11021
cokebank_database cokebank.db
items_file items.cfg
-door_serial_port /dev/ttyS0
-coke_modbus_address 130.95.13.72
+# PLC - coke brain
+#coke_modbus_address 130.95.13.73
+coke_modbus_address 0.0.0.0
-trusted_host 192.168.1.39
-trusted_host 192.168.1.34
-trusted_host 192.168.1.37
+# Zero price items, defaults to off
+test_mode no
+#test_mode yes
+
+# Used to set dispense into a dummy mode when the coke machine is out of action
+# and we're dispensing drinks from the fridge (or manually)
+coke_dummy_mode no
+#coke_dummy_mode yes
+
+door_serial_port /dev/ttyUSB0
+door_unlocked_delay 10
+
+trusted_host 130.95.13.4 # Merlo
+trusted_host 130.95.13.7 # motsugo
+trusted_host 130.95.13.18 # mussel
+trusted_host 130.95.13.23 # martello
+trusted_host 130.95.13.42 # meersau
#define COKEBANK_SALES_ACCT ">sales" //!< Sales made into
#define COKEBANK_SALES_PREFIX ">sales:" //!< Sales made into
-#define COKEBANK_DEBT_ACCT ">countersum" //!< Credit taken out of
+#define COKEBANK_ADDSRC_ACCT ">delta" //!< Credit taken out of
+#define COKEBANK_DEBT_ACCT ">countersum" //!< Balancing account (causes sum to be 0)
#define COKEBANK_FREE_ACCT ">freeitems" //!< ODay drink costs taken out of
#define COKEBANK_DONATE_ACCT ">donations" //!< Donations go here
#define COKEBANK_GRAT_ACCR ">gratuities" //!< Coke runs and new users
extern int DispenseRefund(int ActualUser, int DestUser, tItem *Item, int OverridePrice);
extern int DispenseGive(int ActualUser, int SrcUser, int DestUser, int Ammount, const char *ReasonGiven);
extern int DispenseAdd(int ActualUser, int User, int Ammount, const char *ReasonGiven);
-extern int DispenseSet(int ActualUser, int User, int Balance, const char *ReasonGiven);
+extern int DispenseSet(int ActualUser, int User, int Balance, const char *ReasonGiven, int *OrigBalance);
extern int DispenseDonate(int ActualUser, int User, int Ammount, const char *ReasonGiven);
extern int DispenseUpdateItem(int User, tItem *Item, const char *NewName, int NewPrice);
char *dstName, *byName;
#if DISPENSE_ADD_BELOW_MIN
- ret = _Transfer( Bank_GetAcctByName(COKEBANK_DEBT_ACCT,1), User, Ammount, ReasonGiven );
+ ret = _Transfer( Bank_GetAcctByName(COKEBANK_ADDSRC_ACCT,1), User, Ammount, ReasonGiven );
#else
- ret = Bank_Transfer( Bank_GetAcctByName(COKEBANK_DEBT_ACCT,1), User, Ammount, ReasonGiven );
+ ret = Bank_Transfer( Bank_GetAcctByName(COKEBANK_ADDSRC_ACCT,1), User, Ammount, ReasonGiven );
#endif
if(ret) return 2;
return 0;
}
-int DispenseSet(int ActualUser, int User, int Balance, const char *ReasonGiven)
+int DispenseSet(int ActualUser, int User, int Balance, const char *ReasonGiven, int *OrigBalance)
{
int curBal = Bank_GetBalance(User);
char *byName, *dstName;
byName = Bank_GetAcctName(ActualUser);
dstName = Bank_GetAcctName(User);
- Log_Info("set balance of %s to %i by %s [balance %i] - %s",
- dstName, Balance, byName, Bank_GetBalance(User), ReasonGiven
+ Log_Info("set balance of %s to %i by %s [was %i, balance %i] - %s",
+ dstName, Balance, byName, curBal, Bank_GetBalance(User), ReasonGiven
);
+ *OrigBalance = curBal;
free(byName);
free(dstName);
return ;
}
+ int origBalance, rv;
// Do give
- switch( DispenseSet(Client->UID, uid, iAmmount, reason) )
+ switch( rv = DispenseSet(Client->UID, uid, iAmmount, reason, &origBalance) )
{
case 0:
- sendf(Client->Socket, "200 Add OK\n");
- return ;
- case 2:
- sendf(Client->Socket, "402 Poor Guy\n");
+ sendf(Client->Socket, "200 Add OK (%i)\n", origBalance);
return ;
default:
- sendf(Client->Socket, "500 Unknown error\n");
+ sendf(Client->Socket, "500 Unknown error (%i)\n", rv);
return ;
}
}