I am trying to log a process in C and I need an simpler solution.
I have a status byte of which each bit indicates if certain equipment is on. Each equipment has a fixed power consumption rate and I want to log the power usage based on its ON/OFF status.
So, I have a struct called equip_totals and the usage rates as members, equip1…
struct {
unsigned int equip1;
unsigned int equip2;
...
} equip_totals;
and to update, I use a rather long function which I would like to simplify
void update_equip_status(char *equip_status)
{
if (&equip_staus = 0x01)
equip_totals.equip1 = consumption_rate*time;
if...
}
If you have any ideas, I would appreciate it.
Replace equip_totals with array and use the following loop