I am using a structure to maintain variables for a collection of objects, where some of these attributes are bool variables that are used to store status flags that get set throughout the code.
Thinking of the structure as a table, at various points in the code, I need to know if any row has a true in a given column. I've done this with a loop, but I'm wondering if there is a more elegant method to achieve this, like the Java isAllTrue method.
Struct shown here:
struct toolVariables
//
// Structured array for tracking all tool attributes
{
char* toolName; // name of the tool
int sensorBaseline; // baseline value for tool current sensor
int toolDelta; // threshold value for current sensor
int numberReadings; // numer of readings taken from the sensor each cycle
int sensorAverage; // smoothed average of sensor readings this cycle
bool toolOverrideSet; // semaphore to track if tool override is activated
bool gateActive; // semaphore to track if gate is active
bool gateCallRequest; // semaphore to track status of the blast gate call request
bool gateSpindownStatus; // semaphore to track if tool gate is in spindown
int gateSpindownDelay; // number of miliseconds to keep running after tool stops
unsigned long gateSpindownEnd; // millisecond counter time when spindown ends
int sensorPin; // analog pin for current sensor
int gatePin; // digital pin controlling blast gate
int overridePin; // digital pin for manual override switch
}
toolArray[] =
//
// Listing of each tool and its associated attributes
//
// Tools should be ordered so the most common use tools are at the top to ensure
// the most efficient operation of the dustCollection function.
{
{"future", 585, 9999, 10, 0, false, false, false, false, 10000, 0, A0, 48, 27},
{"Shop Cleanup", 600, 9999, 10, 0, false, false, false, false, 10000, 0, A4, 47, 26},
{"Chop Saw", 600, 50, 10, 0, false, false, false, false, 30000, 0, A8, 44, 25},
{"Shaper/Wide Belt", 600, 9999, 10, 0, false, false, false, false, 6000, 0, A12, 45, 24},
{"Bandsaw", 320, 9999, 10, 0, false, false, false, false, 6000, 0, A1, 42, 23},
{"Planer", 320, 75, 10, 0, false, false, false, false, 10000, 0, A5, 46, 22},
{"Jointer", 320, 75, 10, 0, false, false, false, false, 10000, 0, A9, 49, 31},
{"Belt Sander", 320, 9999, 10, 0, false, false, false, false, 5000, 0, A13, 43, 28},
{"Work Bench", 600, 100, 10, 0, false, false, false, false, 5000, 0, A14, 40, 29},
{"Table Saw", 600, 100, 10, 0, false, false, false, false, 20000, 0, A10, 41, 30},
{"HighBay Cleanup", 600, 100, 10, 0, false, false, false, false, 5000, 0, A6, 38, 34},
{"HighBay Overhead", 320, 9999, 10, 0, false, false, false, false, 5000, 0, A2, 39, 36}
};
Thanks,
Chuck