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:
Tue Dec 29 23:31:28 2015 +0000
Revision:
7:6723f6887d00
Child:
8:d98e2dec0f40
motion block alerts, more commands

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 7:6723f6887d00 38 char* msg = "Arm could not be moved 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 7:6723f6887d00 44 if (slen < 0)
henryrawas 7:6723f6887d00 45 {
henryrawas 7:6723f6887d00 46 strcpy(Msg, "Arm could not be moved to desired position.");
henryrawas 7:6723f6887d00 47 }
henryrawas 7:6723f6887d00 48 }