aboutsummaryrefslogtreecommitdiffstats
path: root/src/amps
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-05-25 18:43:54 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2017-06-10 13:08:21 +0200
commit6adfcf74664a30021f12cc84e00a7cd471ee81a1 (patch)
tree5f9398057fe84a68ccd1d72f6d83a2aaa020bea4 /src/amps
parentbb64c6b3ba80f8ef844bae59e270ca9e3b43d1fd (diff)
Status display
Alows to show status of current channels and users
Diffstat (limited to 'src/amps')
-rw-r--r--src/amps/amps.c17
-rw-r--r--src/amps/amps.h1
-rw-r--r--src/amps/transaction.c36
-rw-r--r--src/amps/transaction.h1
4 files changed, 55 insertions, 0 deletions
diff --git a/src/amps/amps.c b/src/amps/amps.c
index d180a4f..5d57d63 100644
--- a/src/amps/amps.c
+++ b/src/amps/amps.c
@@ -272,12 +272,29 @@ const char *amps_state_name(enum amps_state state)
return invalid;
}
+void amps_display_status(void)
+{
+ sender_t *sender;
+ amps_t *amps;
+ transaction_t *trans;
+
+ display_status_start();
+ for (sender = sender_head; sender; sender = sender->next) {
+ amps = (amps_t *) sender;
+ display_status_channel(amps->sender.kanal, chan_type_short_name(amps->chan_type), amps_state_name(amps->state));
+ for (trans = amps->trans_list; trans; trans = trans->next)
+ display_status_subscriber(amps_min2number(trans->min1, trans->min2), trans_short_state_name(trans->state));
+ }
+ display_status_end();
+}
+
static void amps_new_state(amps_t *amps, enum amps_state new_state)
{
if (amps->state == new_state)
return;
PDEBUG_CHAN(DAMPS, DEBUG_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state));
amps->state = new_state;
+ amps_display_status();
}
static struct amps_channels {
diff --git a/src/amps/amps.h b/src/amps/amps.h
index db5fa64..6243f74 100644
--- a/src/amps/amps.h
+++ b/src/amps/amps.h
@@ -174,4 +174,5 @@ void amps_rx_sat(amps_t *amps, int tone, double quality);
void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_t min1, uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order, const char *dialing);
transaction_t *amps_tx_frame_focc(amps_t *amps);
transaction_t *amps_tx_frame_fvc(amps_t *amps);
+void amps_display_status();
diff --git a/src/amps/transaction.c b/src/amps/transaction.c
index ea47a67..eac29e4 100644
--- a/src/amps/transaction.c
+++ b/src/amps/transaction.c
@@ -68,6 +68,39 @@ static const char *trans_state_name(int state)
}
}
+const char *trans_short_state_name(int state)
+{
+ switch (state) {
+ case 0:
+ return "IDLE";
+ case TRANS_REGISTER_ACK:
+ case TRANS_REGISTER_ACK_SEND:
+ return "REGISTER";
+ case TRANS_CALL_MO_ASSIGN:
+ case TRANS_CALL_MO_ASSIGN_SEND:
+ case TRANS_CALL_MT_ASSIGN:
+ case TRANS_CALL_MT_ASSIGN_SEND:
+ return "ASSIGN";
+ case TRANS_CALL_MT_ALERT:
+ case TRANS_CALL_MT_ALERT_SEND:
+ return "ALERT";
+ case TRANS_CALL_REJECT:
+ case TRANS_CALL_REJECT_SEND:
+ return "REJECT";
+ case TRANS_CALL:
+ return "CALL";
+ case TRANS_CALL_RELEASE:
+ case TRANS_CALL_RELEASE_SEND:
+ return "RELEASE";
+ case TRANS_PAGE:
+ case TRANS_PAGE_SEND:
+ case TRANS_PAGE_REPLY:
+ return "PAGE";
+ default:
+ return "<invald transaction state>";
+ }
+}
+
/* create transaction */
transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uint32_t min1, uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order, uint16_t chan)
{
@@ -139,6 +172,7 @@ void link_transaction(transaction_t *trans, amps_t *amps)
while (*transp)
transp = &((*transp)->next);
*transp = trans;
+ amps_display_status();
}
/* unlink transaction from list */
@@ -157,6 +191,7 @@ void unlink_transaction(transaction_t *trans)
}
*transp = trans->next;
trans->amps = NULL;
+ amps_display_status();
}
transaction_t *search_transaction_number(amps_t *amps, uint32_t min1, uint16_t min2)
@@ -199,6 +234,7 @@ void trans_new_state(transaction_t *trans, int state)
{
PDEBUG(DTRANS, DEBUG_INFO, "Transaction state %s -> %s\n", trans_state_name(trans->state), trans_state_name(state));
trans->state = state;
+ amps_display_status();
}
void amps_flush_other_transactions(amps_t *amps, transaction_t *trans)
diff --git a/src/amps/transaction.h b/src/amps/transaction.h
index 79fd467..5327481 100644
--- a/src/amps/transaction.h
+++ b/src/amps/transaction.h
@@ -49,4 +49,5 @@ transaction_t *search_transaction_callref(amps_t *amps, int callref);
void trans_new_state(transaction_t *trans, int state);
void amps_flush_other_transactions(amps_t *amps, transaction_t *trans);
void transaction_timeout(struct timer *timer);
+const char *trans_short_state_name(int state);