demo project

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Committer:
henryrawas
Date:
Thu Dec 31 17:47:55 2015 +0000
Revision:
8:d98e2dec0f40
Parent:
7:6723f6887d00
Child:
13:ffeff9b5e513
add taps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
henryrawas 7:6723f6887d00 1 #include "mbed.h"
henryrawas 7:6723f6887d00 2 #include "crt_abstractions.h"
henryrawas 7:6723f6887d00 3
henryrawas 7:6723f6887d00 4 #include "Alert.h"
henryrawas 7:6723f6887d00 5
henryrawas 7:6723f6887d00 6
henryrawas 7:6723f6887d00 7
henryrawas 7:6723f6887d00 8 SafeCircBuf<Alert, AlertBufSize, uint32_t> AlertBuf;
henryrawas 7:6723f6887d00 9
henryrawas 7:6723f6887d00 10 void Alert::SetAlert(int severity, time_t created, char* msg, char* atype)
henryrawas 7:6723f6887d00 11 {
henryrawas 7:6723f6887d00 12 Sev = severity;
henryrawas 7:6723f6887d00 13 Created = created;
henryrawas 7:6723f6887d00 14
henryrawas 7:6723f6887d00 15 if (strlen(atype) >= AlertTypeMaxLen)
henryrawas 7:6723f6887d00 16 {
henryrawas 7:6723f6887d00 17 strncpy(AlertType, atype, AlertTypeMaxLen);
henryrawas 7:6723f6887d00 18 AlertType[AlertTypeMaxLen - 1] = 0;
henryrawas 7:6723f6887d00 19 }
henryrawas 7:6723f6887d00 20 else
henryrawas 7:6723f6887d00 21 {
henryrawas 7:6723f6887d00 22 strcpy(AlertType, atype);
henryrawas 7:6723f6887d00 23 }
henryrawas 7:6723f6887d00 24 if (strlen(msg) >= AlertMsgMaxLen)
henryrawas 7:6723f6887d00 25 {
henryrawas 7:6723f6887d00 26 strncpy(Msg, msg, AlertMsgMaxLen);
henryrawas 7:6723f6887d00 27 Msg[AlertMsgMaxLen - 1] = 0;
henryrawas 7:6723f6887d00 28 }
henryrawas 7:6723f6887d00 29 else
henryrawas 7:6723f6887d00 30 {
henryrawas 7:6723f6887d00 31 strcpy(Msg, msg);
henryrawas 7:6723f6887d00 32 }
henryrawas 7:6723f6887d00 33 }
henryrawas 7:6723f6887d00 34
henryrawas 7:6723f6887d00 35
henryrawas 7:6723f6887d00 36 void Alert::SetPositionAlert(int severity, time_t created, int partIx, float diff)
henryrawas 7:6723f6887d00 37 {
henryrawas 8:d98e2dec0f40 38 char* msg = "Arm part failed to move to desired position. Part %d is off by %f";
henryrawas 7:6723f6887d00 39 int slen = sprintf_s(Msg, AlertMsgMaxLen, msg, partIx, diff);
henryrawas 7:6723f6887d00 40 Sev = severity;
henryrawas 7:6723f6887d00 41 Created = created;
henryrawas 7:6723f6887d00 42
henryrawas 7:6723f6887d00 43 strcpy(AlertType, "Position");
henryrawas 8:d98e2dec0f40 44 }
henryrawas 8:d98e2dec0f40 45
henryrawas 8:d98e2dec0f40 46 void Alert::SetHardwareAlert(int severity, time_t created, int partIx, int code)
henryrawas 8:d98e2dec0f40 47 {
henryrawas 8:d98e2dec0f40 48 char* msg = "Arm part reported an error. Part %d error code %d";
henryrawas 8:d98e2dec0f40 49 int slen = sprintf_s(Msg, AlertMsgMaxLen, msg, partIx, code);
henryrawas 8:d98e2dec0f40 50 Sev = severity;
henryrawas 8:d98e2dec0f40 51 Created = created;
henryrawas 8:d98e2dec0f40 52
henryrawas 8:d98e2dec0f40 53 strcpy(AlertType, "Hardware");
henryrawas 7:6723f6887d00 54 }
henryrawas 8:d98e2dec0f40 55
henryrawas 8:d98e2dec0f40 56 void Alert::SetTemperatureAlert(int severity, time_t created, int partIx, float temp)
henryrawas 8:d98e2dec0f40 57 {
henryrawas 8:d98e2dec0f40 58 char* msg = "Arm part reported a high temperature. Part %d temperature %f";
henryrawas 8:d98e2dec0f40 59 int slen = sprintf_s(Msg, AlertMsgMaxLen, msg, partIx, temp);
henryrawas 8:d98e2dec0f40 60 Sev = severity;
henryrawas 8:d98e2dec0f40 61 Created = created;
henryrawas 8:d98e2dec0f40 62
henryrawas 8:d98e2dec0f40 63 strcpy(AlertType, "Temperature");
henryrawas 8:d98e2dec0f40 64 }