Remove function, replacing with capturing, analysing, recording. Adjust formatting of list function
This commit is contained in:
parent
c524298f8e
commit
ad32466aa4
74
src/zmu.cpp
74
src/zmu.cpp
|
@ -498,9 +498,9 @@ int main(int argc, char *argv[]) {
|
||||||
printf("Monitor %u(%s)\n", monitor->Id(), monitor->Name());
|
printf("Monitor %u(%s)\n", monitor->Id(), monitor->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor->GetFunction() == Monitor::NONE) {
|
if (monitor->Capturing() == Monitor::CAPTURING_NONE) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("Current state: None\n");
|
printf("Current capturing state: None\n");
|
||||||
} else {
|
} else {
|
||||||
printf("%d", Monitor::UNKNOWN);
|
printf("%d", Monitor::UNKNOWN);
|
||||||
}
|
}
|
||||||
|
@ -603,35 +603,31 @@ int main(int argc, char *argv[]) {
|
||||||
monitor->DumpZoneImage(zoneString);
|
monitor->DumpZoneImage(zoneString);
|
||||||
}
|
}
|
||||||
if ( function & ZMU_ALARM ) {
|
if ( function & ZMU_ALARM ) {
|
||||||
if ( monitor->GetFunction() == Monitor::Function::MONITOR ) {
|
Monitor::State state = monitor->GetState();
|
||||||
printf("A Monitor in monitor mode cannot handle alarms. Please use NoDect\n");
|
|
||||||
|
if (verbose) {
|
||||||
|
printf("Forcing alarm on current state: %s, event %" PRIu64 "\n",
|
||||||
|
state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle"),
|
||||||
|
monitor->GetLastEventId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that we are not recording. So the forced alarm is distinct from what was recording before
|
||||||
|
monitor->ForceAlarmOff();
|
||||||
|
monitor->ForceAlarmOn(config.forced_alarm_score, "Forced Web");
|
||||||
|
|
||||||
|
Microseconds wait_time = Seconds(10);
|
||||||
|
while ((monitor->GetState() != Monitor::ALARM) and !zm_terminate and wait_time > Seconds(0)) {
|
||||||
|
// Wait for monitor to notice.
|
||||||
|
Microseconds sleep = Microseconds(1);
|
||||||
|
std::this_thread::sleep_for(sleep);
|
||||||
|
wait_time -= sleep;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monitor->GetState() != Monitor::ALARM and wait_time == Seconds(0)) {
|
||||||
|
Error("Monitor failed to respond to forced alarm.");
|
||||||
} else {
|
} else {
|
||||||
Monitor::State state = monitor->GetState();
|
printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId());
|
||||||
|
|
||||||
if ( verbose ) {
|
|
||||||
printf("Forcing alarm on current state: %s, event %" PRIu64 "\n",
|
|
||||||
state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle"),
|
|
||||||
monitor->GetLastEventId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that we are not recording. So the forced alarm is distinct from what was recording before
|
|
||||||
monitor->ForceAlarmOff();
|
|
||||||
monitor->ForceAlarmOn(config.forced_alarm_score, "Forced Web");
|
|
||||||
|
|
||||||
Microseconds wait_time = Seconds(10);
|
|
||||||
while ((monitor->GetState() != Monitor::ALARM) and !zm_terminate and wait_time > Seconds(0)) {
|
|
||||||
// Wait for monitor to notice.
|
|
||||||
Microseconds sleep = Microseconds(1);
|
|
||||||
std::this_thread::sleep_for(sleep);
|
|
||||||
wait_time -= sleep;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitor->GetState() != Monitor::ALARM and wait_time == Seconds(0)) {
|
|
||||||
Error("Monitor failed to respond to forced alarm.");
|
|
||||||
} else {
|
|
||||||
printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // end if ZMU_ALARM
|
} // end if ZMU_ALARM
|
||||||
|
|
||||||
|
@ -756,9 +752,9 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function & ZMU_LIST ) {
|
if ( function & ZMU_LIST ) {
|
||||||
std::string sql = "SELECT `Id`, `Function`+0 FROM `Monitors`";
|
std::string sql = "SELECT `Id`, `Capturing`+0, `Analysing`+0, `Recording`+0 FROM `Monitors`";
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
sql += "WHERE `Function` != 'None'";
|
sql += " WHERE `Capturing` != 'None'";
|
||||||
}
|
}
|
||||||
sql += " ORDER BY Id ASC";
|
sql += " ORDER BY Id ASC";
|
||||||
|
|
||||||
|
@ -768,19 +764,23 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
Debug(1, "Got %" PRIu64 " monitors", static_cast<uint64>(mysql_num_rows(result)));
|
Debug(1, "Got %" PRIu64 " monitors", static_cast<uint64>(mysql_num_rows(result)));
|
||||||
|
|
||||||
printf("%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate");
|
printf("%4s %9s %9s %9s %5s %8s %13s %5s %5s %9s %9s\n",
|
||||||
|
"Id", "Capturing", "Analysing", "Recording", "State", "TrgState",
|
||||||
|
"LastImageTime", "RdIdx", "WrIdx", "LastEvent", "FrameRate");
|
||||||
for ( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row(result); i++ ) {
|
for ( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row(result); i++ ) {
|
||||||
int monitor_id = atoi(dbrow[0]);
|
int monitor_id = atoi(dbrow[0]);
|
||||||
int monitor_function = atoi(dbrow[1]);
|
int monitor_capturing = atoi(dbrow[1]);
|
||||||
if ( !user || user->canAccess(monitor_id) ) {
|
if ( !user || user->canAccess(monitor_id) ) {
|
||||||
if ( monitor_function > 1 ) {
|
if (monitor_capturing > Monitor::CAPTURING_NONE) {
|
||||||
std::shared_ptr<Monitor> monitor = Monitor::Load(monitor_id, false, Monitor::QUERY);
|
std::shared_ptr<Monitor> monitor = Monitor::Load(monitor_id, false, Monitor::QUERY);
|
||||||
if ( monitor && monitor->connect() ) {
|
if ( monitor && monitor->connect() ) {
|
||||||
SystemTimePoint timestamp = monitor->GetTimestamp();
|
SystemTimePoint timestamp = monitor->GetTimestamp();
|
||||||
|
|
||||||
printf( "%4d%5d%6d%9d%14.2f%6d%6d%8" PRIu64 "%8.2f\n",
|
printf("%4d %9d %9d %9d %5d %8d %13.2f %5d %5d %9" PRIu64 "%10.2f\n",
|
||||||
monitor->Id(),
|
monitor->Id(),
|
||||||
monitor_function,
|
monitor->Capturing(),
|
||||||
|
monitor->Analysing(),
|
||||||
|
monitor->Recording(),
|
||||||
monitor->GetState(),
|
monitor->GetState(),
|
||||||
monitor->GetTriggerState(),
|
monitor->GetTriggerState(),
|
||||||
FPSeconds(timestamp.time_since_epoch()).count(),
|
FPSeconds(timestamp.time_since_epoch()).count(),
|
||||||
|
|
Loading…
Reference in New Issue