Skip to content

Commit

Permalink
clang-format: Change line break of function arguments
Browse files Browse the repository at this point in the history
clang-format options:
  BinPackArguments: false
  AllowAllArgumentsOnNextLine: false
  BinPackParameters: false
  AllowAllParametersOfDeclarationOnNextLine: false
  • Loading branch information
pataxis committed Nov 28, 2023
1 parent bed44fc commit eef4ecf
Show file tree
Hide file tree
Showing 31 changed files with 991 additions and 328 deletions.
6 changes: 5 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
BasedOnStyle: LLVM
# Cpp covers both C and C++.
Language: Cpp
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: true
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 100
IndentCaseLabels: true
# Most files have used this indentation width and to not get to large diffs
Expand Down
59 changes: 44 additions & 15 deletions axevent/send_event/app/send_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ static gboolean send_event(AppData* app_data) {

// Add the variable elements of the event to the set
syslog(LOG_INFO, "Add value: %lf", app_data->value);
ax_event_key_value_set_add_key_value(key_value_set, "Value", NULL, &app_data->value,
AX_VALUE_TYPE_DOUBLE, NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"Value",
NULL,
&app_data->value,
AX_VALUE_TYPE_DOUBLE,
NULL);

// Create the event
// Use ax_event_new2 since ax_event_new is deprecated from 3.2
Expand Down Expand Up @@ -126,26 +130,51 @@ static guint setup_declaration(AXEventHandler* event_handler) {

// Create keys, namespaces and nice names for the event
key_value_set = ax_event_key_value_set_new();
ax_event_key_value_set_add_key_value(key_value_set, "topic0", "tns1", "Monitoring",
AX_VALUE_TYPE_STRING, NULL);
ax_event_key_value_set_add_key_value(key_value_set, "topic1", "tns1", "ProcessorUsage",
AX_VALUE_TYPE_STRING, NULL);
ax_event_key_value_set_add_key_value(key_value_set, "Token", NULL, &token, AX_VALUE_TYPE_INT,
ax_event_key_value_set_add_key_value(key_value_set,
"topic0",
"tns1",
"Monitoring",
AX_VALUE_TYPE_STRING,
NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"topic1",
"tns1",
"ProcessorUsage",
AX_VALUE_TYPE_STRING,
NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"Token",
NULL,
&token,
AX_VALUE_TYPE_INT,
NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"Value",
NULL,
&start_value,
AX_VALUE_TYPE_DOUBLE,
NULL);
ax_event_key_value_set_add_key_value(key_value_set, "Value", NULL, &start_value,
AX_VALUE_TYPE_DOUBLE, NULL);
ax_event_key_value_set_mark_as_source(key_value_set, "Token", NULL, NULL);
ax_event_key_value_set_mark_as_user_defined(key_value_set, "Token", NULL,
"wstype:tt:ReferenceToken", NULL);
ax_event_key_value_set_mark_as_user_defined(key_value_set,
"Token",
NULL,
"wstype:tt:ReferenceToken",
NULL);
ax_event_key_value_set_mark_as_data(key_value_set, "Value", NULL, NULL);
ax_event_key_value_set_mark_as_user_defined(key_value_set, "Value", NULL, "wstype:xs:float",
ax_event_key_value_set_mark_as_user_defined(key_value_set,
"Value",
NULL,
"wstype:xs:float",
NULL);

// Declare event
if (!ax_event_handler_declare(event_handler, key_value_set,
if (!ax_event_handler_declare(event_handler,
key_value_set,
FALSE, // Indicate a property state event
&declaration, (AXDeclarationCompleteCallback)declaration_complete,
&start_value, &error)) {
&declaration,
(AXDeclarationCompleteCallback)declaration_complete,
&start_value,
&error)) {
syslog(LOG_WARNING, "Could not declare: %s", error->message);
g_error_free(error);
}
Expand Down
24 changes: 18 additions & 6 deletions axevent/subscribe_to_event/app/subscribe_to_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,29 @@ static guint onviftrigger_subscription(AXEventHandler* event_handler, guint* tok
key_value_set = ax_event_key_value_set_new();

// Set keys and namespaces for the event to be subscribed
ax_event_key_value_set_add_key_value(key_value_set, "topic0", "tns1", "Monitoring",
AX_VALUE_TYPE_STRING, NULL);
ax_event_key_value_set_add_key_value(key_value_set, "topic1", "tns1", "ProcessorUsage",
AX_VALUE_TYPE_STRING, NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"topic0",
"tns1",
"Monitoring",
AX_VALUE_TYPE_STRING,
NULL);
ax_event_key_value_set_add_key_value(key_value_set,
"topic1",
"tns1",
"ProcessorUsage",
AX_VALUE_TYPE_STRING,
NULL);

/*
* Time to setup the subscription. Use the "token" input argument as
* input data to the callback function "subscription callback"
*/
ax_event_handler_subscribe(event_handler, key_value_set, &subscription,
(AXSubscriptionCallback)subscription_callback, token, NULL);
ax_event_handler_subscribe(event_handler,
key_value_set,
&subscription,
(AXSubscriptionCallback)subscription_callback,
token,
NULL);

syslog(LOG_INFO, "And here's the token: %d", *token);

Expand Down
142 changes: 116 additions & 26 deletions axevent/subscribe_to_events/app/subscribe_to_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ static void common_callback(guint subscription, AXEvent* event, guint* token) {
syslog(LOG_INFO,
"%d:audiotrigger-event: Audio channel %d above "
"trigger level",
*token, channel);
*token,
channel);
} else {
syslog(LOG_INFO,
"%d:audiotrigger-event: Audio channel %d below "
"trigger level",
*token, channel);
*token,
channel);
}

} else if (*token == DAYNIGHT_TOKEN) {
Expand All @@ -112,7 +114,9 @@ static void common_callback(guint subscription, AXEvent* event, guint* token) {
if (state) {
syslog(LOG_INFO, "%d:manualtrigger-event: Trigger on port %d is active", *token, port);
} else {
syslog(LOG_INFO, "%d:manualtrigger-event: Trigger on port %d is inactive", *token,
syslog(LOG_INFO,
"%d:manualtrigger-event: Trigger on port %d is inactive",
*token,
port);
}

Expand Down Expand Up @@ -155,16 +159,23 @@ static void ptzmove_callback(guint subscription, AXEvent* event, ptzmove* data)
key_value_set = ax_event_get_key_value_set(event);

// Get the state of the manual trigger port
ax_event_key_value_set_get_integer(key_value_set, "PTZConfigurationToken", NULL, &channel,
ax_event_key_value_set_get_integer(key_value_set,
"PTZConfigurationToken",
NULL,
&channel,
NULL);
ax_event_key_value_set_get_boolean(key_value_set, "is_moving", NULL, &is_moving, NULL);

// Print channel and if moving or stopped
if (is_moving) {
data->ptzchannel[channel].num_moves += 1;
val = (data->ptzchannel[channel].num_moves == 1);
syslog(LOG_INFO, "%d:ptzmove-event: PTZ channel %d started moving (%d %s)", data->id,
channel, data->ptzchannel[channel].num_moves, val ? "time" : "times");
syslog(LOG_INFO,
"%d:ptzmove-event: PTZ channel %d started moving (%d %s)",
data->id,
channel,
data->ptzchannel[channel].num_moves,
val ? "time" : "times");
} else {
if (data->ptzchannel[channel].num_moves > 0) {
syslog(LOG_INFO, "%d:ptzmove-event: PTZ channel %d stopped moving", data->id, channel);
Expand Down Expand Up @@ -202,10 +213,25 @@ static guint audiotrigger_subscription(AXEventHandler* event_handler, guint toke
* channel=NULL <-- Subscribe to all channels
* triggered=NULL <-- Subscribe to all states
*/
ax_event_key_value_set_add_key_values(
key_value_set, NULL, "topic0", "tns1", "AudioSource", AX_VALUE_TYPE_STRING, "topic1",
"tnsaxis", "TriggerLevel", AX_VALUE_TYPE_STRING, "channel", NULL, NULL, AX_VALUE_TYPE_INT,
"triggered", NULL, NULL, AX_VALUE_TYPE_BOOL, NULL);
ax_event_key_value_set_add_key_values(key_value_set,
NULL,
"topic0",
"tns1",
"AudioSource",
AX_VALUE_TYPE_STRING,
"topic1",
"tnsaxis",
"TriggerLevel",
AX_VALUE_TYPE_STRING,
"channel",
NULL,
NULL,
AX_VALUE_TYPE_INT,
"triggered",
NULL,
NULL,
AX_VALUE_TYPE_BOOL,
NULL);

// Setup subscription and connect to callback function
ax_event_handler_subscribe(event_handler, // event handler
Expand Down Expand Up @@ -245,10 +271,25 @@ static guint daynight_subscription(AXEventHandler* event_handler, guint token) {
* VideoSource...=NULL <-- Subscribe to all values
* day=NULL <-- Subscribe to all states
*/
ax_event_key_value_set_add_key_values(
key_value_set, NULL, "topic0", "tns1", "VideoSource", AX_VALUE_TYPE_STRING, "topic1",
"tnsaxis", "DayNightVision", AX_VALUE_TYPE_STRING, "VideoSourceConfigurationToken", NULL,
NULL, AX_VALUE_TYPE_INT, "day", NULL, NULL, AX_VALUE_TYPE_BOOL, NULL);
ax_event_key_value_set_add_key_values(key_value_set,
NULL,
"topic0",
"tns1",
"VideoSource",
AX_VALUE_TYPE_STRING,
"topic1",
"tnsaxis",
"DayNightVision",
AX_VALUE_TYPE_STRING,
"VideoSourceConfigurationToken",
NULL,
NULL,
AX_VALUE_TYPE_INT,
"day",
NULL,
NULL,
AX_VALUE_TYPE_BOOL,
NULL);

// Setup subscription and connect to callback function
ax_event_handler_subscribe(event_handler, // event handler
Expand Down Expand Up @@ -290,10 +331,29 @@ static guint manualtrigger_subscription(AXEventHandler* event_handler, guint tok
* port=&port <-- Subscribe to port number 1
* state=NULL <-- Subscribe to all states
*/
ax_event_key_value_set_add_key_values(
key_value_set, NULL, "topic0", "tns1", "Device", AX_VALUE_TYPE_STRING, "topic1", "tnsaxis",
"IO", AX_VALUE_TYPE_STRING, "topic2", "tnsaxis", "VirtualPort", AX_VALUE_TYPE_STRING,
"port", NULL, &port, AX_VALUE_TYPE_INT, "state", NULL, NULL, AX_VALUE_TYPE_BOOL, NULL);
ax_event_key_value_set_add_key_values(key_value_set,
NULL,
"topic0",
"tns1",
"Device",
AX_VALUE_TYPE_STRING,
"topic1",
"tnsaxis",
"IO",
AX_VALUE_TYPE_STRING,
"topic2",
"tnsaxis",
"VirtualPort",
AX_VALUE_TYPE_STRING,
"port",
NULL,
&port,
AX_VALUE_TYPE_INT,
"state",
NULL,
NULL,
AX_VALUE_TYPE_BOOL,
NULL);

// Setup subscription and connect to callback function
ax_event_handler_subscribe(event_handler, // event handler
Expand Down Expand Up @@ -333,10 +393,25 @@ static guint ptzmove_subscription(AXEventHandler* event_handler, ptzmove* data)
* channel=NULL <-- Subscribe to all PTZ channels
* is_moving=NULL <-- Subscribe to all values
*/
ax_event_key_value_set_add_key_values(
key_value_set, NULL, "topic0", "tns1", "PTZController", AX_VALUE_TYPE_STRING, "topic1",
"tnsaxis", "Move", AX_VALUE_TYPE_STRING, "PTZConfigurationToken", NULL, NULL,
AX_VALUE_TYPE_INT, "is_moving", NULL, NULL, AX_VALUE_TYPE_BOOL, NULL);
ax_event_key_value_set_add_key_values(key_value_set,
NULL,
"topic0",
"tns1",
"PTZController",
AX_VALUE_TYPE_STRING,
"topic1",
"tnsaxis",
"Move",
AX_VALUE_TYPE_STRING,
"PTZConfigurationToken",
NULL,
NULL,
AX_VALUE_TYPE_INT,
"is_moving",
NULL,
NULL,
AX_VALUE_TYPE_BOOL,
NULL);

// Setup subscription and connect to callback function
ax_event_handler_subscribe(event_handler, // event handler
Expand Down Expand Up @@ -377,10 +452,25 @@ static guint tampering_subscription(AXEventHandler* event_handler, guint token)
* channel=&channel <-- Subscribe to channel number 1
* tampering=NULL <-- Subscribe to all values
*/
ax_event_key_value_set_add_key_values(
key_value_set, NULL, "topic0", "tns1", "VideoSource", AX_VALUE_TYPE_STRING, "topic1",
"tnsaxis", "Tampering", AX_VALUE_TYPE_STRING, "channel", NULL, &channel, AX_VALUE_TYPE_INT,
"tampering", NULL, NULL, AX_VALUE_TYPE_INT, NULL);
ax_event_key_value_set_add_key_values(key_value_set,
NULL,
"topic0",
"tns1",
"VideoSource",
AX_VALUE_TYPE_STRING,
"topic1",
"tnsaxis",
"Tampering",
AX_VALUE_TYPE_STRING,
"channel",
NULL,
&channel,
AX_VALUE_TYPE_INT,
"tampering",
NULL,
NULL,
AX_VALUE_TYPE_INT,
NULL);

// Setup subscription and connect to callback function
ax_event_handler_subscribe(event_handler, // event handler
Expand Down
Loading

0 comments on commit eef4ecf

Please sign in to comment.