From aafd37dd59cf534be7778f36431cc48adb0a3673 Mon Sep 17 00:00:00 2001 From: Daniela Date: Fri, 12 Apr 2019 16:30:01 +0200 Subject: [PATCH] Cassa and Supermarket updated --- project/Natalia/cassa.c | 43 +---------------- project/common/supermarket_net.h | 82 ++++++++++++++++++++++++++++---- project/msg.h | 71 --------------------------- 3 files changed, 75 insertions(+), 121 deletions(-) delete mode 100644 project/msg.h diff --git a/project/Natalia/cassa.c b/project/Natalia/cassa.c index 0fe235fff..5c21a54b9 100644 --- a/project/Natalia/cassa.c +++ b/project/Natalia/cassa.c @@ -10,54 +10,13 @@ #include "arch/cpu/cc26x0-cc13x0/dev/cc26xx-uart.h" #include +#include "../common/supermarket_net.h" #define MAX_CUSTOMERS 20 -enum message_type{CASH_OUT_MSG, PRODUCT_MSG, ITEM_ELEM_MSG, BASKET_MSG, START_OF_LIST_PRODUCTS_MSG}; -typedef struct basket_msg -{ - enum message_type msg_type; - uint8_t n_products; - uint8_t customer_id; - linkaddr_t* address; - - -}basket_msg; - -typedef struct user_invoice -{ - enum message_type msg_type; - uint8_t n_prods; - float total_sum; - uint8_t customer_id; - linkaddr_t* address_basket; - uint8_t empty; - - -}user_invoice; - -typedef struct cash_out_msg -{ - enum message_type msg_type; - uint8_t customer_id; -}cash_out_msg; - -typedef struct product_msg{ - - enum message_type msg_type; - uint8_t customer_id; - uint8_t product_id; - float prize; - -}product_msg; - -typedef struct msg{ - enum message_type msg_type; - -}msg; PROCESS(cassa_main_process, "Cassa process"); AUTOSTART_PROCESSES(&cassa_main_process); diff --git a/project/common/supermarket_net.h b/project/common/supermarket_net.h index 7a84eaa07..66606fd25 100644 --- a/project/common/supermarket_net.h +++ b/project/common/supermarket_net.h @@ -1,19 +1,85 @@ #ifndef SUPERMARKET_NET_H #define SUPERMARKET_NET_H -enum MsgType { +enum message_type { ASSOCIATION_REQUEST_MSG, ASSOCIATION_REPLY_MSG, BATTERY_STATUS_MSG, ASSIGNMENT_MSG, - PRODUCT_MSG, - CASHOUT_MSG, - ITEM_ELEM_MSG + CASH_OUT_MSG, + PRODUCT_MSG, + ITEM_ELEM_MSG, + BASKET_MSG, + START_OF_LIST_PRODUCTS_MSG }; -struct Msg { - enum MsgType type; - int test; -}; + +typedef struct msg { + enum message_type msg_type; +}msg; + +typedef struct assoc_req_msg +{ + enum message_type msg_type; + uint8_t battery_percentage; + +}assoc_req_msg; + + +typedef struct assoc_reply_msg +{ + enum message_type msg_type; +}assoc_reply_msg; + + +typedef struct battery_msg +{ + enum message_type msg_type; + uint8_t battery_percentage; +}battery_msg; + + +typedef struct assign_msg +{ + enum message_type msg_type; + uint32_t customer_id; +}assing_msg; + + +typedef struct basket_msg +{ + enum message_type msg_type; + uint8_t n_products; + uint8_t customer_id; + linkaddr_t* address; +}basket_msg; + + +typedef struct cash_out_msg +{ + enum message_type msg_type; + uint8_t customer_id; +}cash_out_msg; + + +typedef struct product_msg +{ + enum message_type msg_type; + uint8_t customer_id; + uint8_t product_id; + float prize; + +}product_msg; + +typedef struct user_invoice +{ + uint8_t n_prods; + float total_sum; + uint8_t customer_id; + linkaddr_t* address_basket; + uint8_t empty; + + +}user_invoice; #endif diff --git a/project/msg.h b/project/msg.h deleted file mode 100644 index 958e72679..000000000 --- a/project/msg.h +++ /dev/null @@ -1,71 +0,0 @@ - -enum message_type{ASSOCIATION_REQUEST_MSG, ASSOCIATION_REPLY_MSG, BATTERY_STATUS_MSG, ASSIGNMENT_MSG, CASH_OUT_MSG, PRODUCT_MSG, ITEM_ELEM_MSG, BASKET_MSG, START_OF_LIST_PRODUCTS_MSG}; - -/*typedef struct assoc_req_msg -{ - uint8_t battery_percentage; - -}assoc_req_msg; - - -typedef struct assoc_reply_msg -{ - //linkaddr_t* assigner_address; -}assoc_reply_msg; - - -typedef struct battery_msg -{ - uint8_t battery_percentage; -}battery_msg; - - -typedef struct assign_msg -{ - uint32_t customer_id; -}assing_msg; -*/ - -typedef struct basket_msg -{ - uint8_t n_products; - uint8_t customer_id; - linkaddr_t* address; - - -}basket_msg; - - -typedef struct cash_out_msg -{ - uint8_t customer_id; -}cash_out_msg; - - -typedef struct product_msg{ - - uint8_t customer_id; - uint8_t product_id; - float prize; - -}product_msg; - -//-----------------------Definition of the type of messages exchanged between the modules, with their useful informations. The significant fields are discriminated by the msg_type --------- - - -typedef struct assigner_msg //Message for communications between assigner and carts -{ - enum message_type msg_type; - //assoc_req_msg request; - //assoc_reply_msg reply; - uint8_t battery_percentage; - uint32_t customer_id; -}a_msg; - -typedef struct cash_desk_msg -{ - enum message_type msg_type; - cash_out_msg cash_out; - product_msg product; - basket_msg basket; -}cd_msg;