CommunicationProtocol.h
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// CommunicationProtocol.h
// DUREX Vendor Control
//
// Created by Imanol Barba on 5/23/14.
// Copyright (c) 2014 Emmoco. All rights reserved.
//
@class CommunicationProtocol;
#import <Foundation/Foundation.h>
#import "EMFramework.h"
#define SLEEP_TIME ((NSTimeInterval)0.1)
#define MAX_STRING_LENGTH ((int)200)
#define MAX_RETRIES ((int)3)
#define MAX_PRODUCT_NAME_LENGTH ((int)64)
#define MAX_CHANNELS ((int)16)
#define MONEY_IN_NUM_UNITS ((int)6)
#define MONEY_OUT_NUM_UNITS ((int)3)
#define CHANGE_NUM_UNITS ((int)2)
#define MAX_PRODUCTS ((int)16)
#define SALE_STRING_LENGTH ((int)36)
#define INCIDENT_STRING_LENGTH ((int)20)
#define REPORT_SERVER_URL @"http://seneca.upc.es:8090/machine"
@protocol CommunicationProtocolDelegate <NSObject>
- (void)processMessage:(CommunicationProtocol*)protocol didFinishEnteringItem:(NSString*) response;
- (void) reportProtocolError: (CommunicationProtocol*)protocol didFinishEnteringItem:(NSString*) error;
@end
@interface CommunicationProtocol : NSObject
@property (nonatomic, strong) id <CommunicationProtocolDelegate> delegate;
-(void) writeMessage: (NSString*) message;
-(void) readMessage;
-(void) establishConnection;
-(void) disconnect;
-(void) updateTime: (NSDateComponents*) date;
-(void) updatePrice: (uint8_t) channel : (uint8_t) product : (uint8_t) eur : (uint8_t) cents;
-(void) updateProductName: (uint8_t) channel : (uint8_t) product : (NSString*) name;
-(void) readSensorData;
-(void) readSalesLog: (NSDateComponents*) start : (NSDateComponents*) end;
-(void) readIncidentLog: (NSDateComponents*) start : (NSDateComponents*) end;
+(id) sharedProtocol;
@end