Cassa and Supermarket updated

This commit is contained in:
Daniela 2019-04-12 16:30:01 +02:00
parent 3393ab5877
commit aafd37dd59
3 changed files with 75 additions and 121 deletions

View File

@ -10,54 +10,13 @@
#include "arch/cpu/cc26x0-cc13x0/dev/cc26xx-uart.h"
#include <stdlib.h>
#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);

View File

@ -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

View File

@ -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;