The field version of the solarnano grid on the ionQubes

Fork of SolarNanoGridv3 by SONG Project

Committer:
defrost
Date:
Tue Sep 06 06:08:56 2016 +0000
Revision:
36:a5620262f296
Parent:
13:de43f28c0365
Turned off the charge rate update from hub

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 5:57b06b4b47c6 1 /**
defrost 5:57b06b4b47c6 2 *@section DESCRIPTION
defrost 5:57b06b4b47c6 3 * mbed SolarNanogrid Library
defrost 5:57b06b4b47c6 4 * Utility extends SolarNanoGrid.
defrost 5:57b06b4b47c6 5 * Utility Manages the agri-equipment and the GPRS .
defrost 5:57b06b4b47c6 6 * The ID must be FE 00.
defrost 5:57b06b4b47c6 7 *@section LICENSE
defrost 5:57b06b4b47c6 8 * Copyright (c) 2016, Malcolm McCulloch
defrost 5:57b06b4b47c6 9 *
defrost 5:57b06b4b47c6 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
defrost 5:57b06b4b47c6 11 * of this software and associated documentation files (the "Software"), to deal
defrost 5:57b06b4b47c6 12 * in the Software without restriction, including without limitation the rights
defrost 5:57b06b4b47c6 13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
defrost 5:57b06b4b47c6 14 * copies of the Software, and to permit persons to whom the Software is
defrost 5:57b06b4b47c6 15 * furnished to do so, subject to the following conditions:
defrost 5:57b06b4b47c6 16 *
defrost 5:57b06b4b47c6 17 * The above copyright notice and this permission notice shall be included in
defrost 5:57b06b4b47c6 18 * all copies or substantial portions of the Software.
defrost 5:57b06b4b47c6 19 *
defrost 5:57b06b4b47c6 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
defrost 5:57b06b4b47c6 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
defrost 5:57b06b4b47c6 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
defrost 5:57b06b4b47c6 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
defrost 5:57b06b4b47c6 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
defrost 5:57b06b4b47c6 25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
defrost 5:57b06b4b47c6 26 * THE SOFTWARE.
defrost 5:57b06b4b47c6 27 * @file "Utility.h"
defrost 5:57b06b4b47c6 28 */
defrost 5:57b06b4b47c6 29
defrost 5:57b06b4b47c6 30 #ifndef UTILITY_H
defrost 5:57b06b4b47c6 31 #define UTILITY_H
defrost 5:57b06b4b47c6 32 #include <mbed.h>
defrost 5:57b06b4b47c6 33 #include "NRF2401P.h"
defrost 5:57b06b4b47c6 34 #include "nRF24l01.h"
defrost 5:57b06b4b47c6 35 #include "SDFileSystem.h"
defrost 5:57b06b4b47c6 36 #include "SolarNanoGrid.h"
defrost 13:de43f28c0365 37
defrost 5:57b06b4b47c6 38
defrost 5:57b06b4b47c6 39
defrost 5:57b06b4b47c6 40 /** \brief Utility manages the human interface and talks to the lockers.
defrost 5:57b06b4b47c6 41 *
defrost 5:57b06b4b47c6 42 * The config.ini must start with H, The ID must be FE 00.
defrost 5:57b06b4b47c6 43 *
defrost 5:57b06b4b47c6 44 */
defrost 5:57b06b4b47c6 45 class Utility : public SolarNanoGrid
defrost 5:57b06b4b47c6 46 {
defrost 5:57b06b4b47c6 47 public:
defrost 5:57b06b4b47c6 48
defrost 5:57b06b4b47c6 49 // *********************
defrost 5:57b06b4b47c6 50 // * Public variables: *
defrost 5:57b06b4b47c6 51 // *********************
defrost 5:57b06b4b47c6 52 // *********************
defrost 5:57b06b4b47c6 53 // * Public functions: *
defrost 5:57b06b4b47c6 54 // *********************
epgmdm 11:87ab310924f0 55
epgmdm 11:87ab310924f0 56 /**
epgmdm 11:87ab310924f0 57 * Constructor:
epgmdm 11:87ab310924f0 58 */
epgmdm 11:87ab310924f0 59 Utility(FILE* fp, Serial *pc);
epgmdm 11:87ab310924f0 60
epgmdm 11:87ab310924f0 61 // Main loop function:
defrost 13:de43f28c0365 62 virtual void loop(void);
epgmdm 11:87ab310924f0 63
defrost 5:57b06b4b47c6 64 protected:
defrost 5:57b06b4b47c6 65 // *********************
defrost 5:57b06b4b47c6 66 // * Protected hardware: *
defrost 5:57b06b4b47c6 67 // *********************
epgmdm 11:87ab310924f0 68 DigitalOut *husker; /**< DigitalOut(PTD1,0);*/
epgmdm 11:87ab310924f0 69 DigitalOut *incubator; /**< DigitalOut(PTD3,0);*/
epgmdm 11:87ab310924f0 70 DigitalOut *posho; /**< DigitalOut(PTD2,0); */
epgmdm 11:87ab310924f0 71 InterruptIn* button;
epgmdm 11:87ab310924f0 72 Ticker* rxWatch;
epgmdm 11:87ab310924f0 73 Ticker* oneSecond;
defrost 5:57b06b4b47c6 74
defrost 5:57b06b4b47c6 75 // *********************
defrost 5:57b06b4b47c6 76 // * Protected flags: *
defrost 5:57b06b4b47c6 77 // *********************
defrost 5:57b06b4b47c6 78
epgmdm 11:87ab310924f0 79 volatile bool flagRotate;
epgmdm 11:87ab310924f0 80 volatile char flagNrf;
epgmdm 11:87ab310924f0 81 volatile char flagOneSecond;
defrost 5:57b06b4b47c6 82
defrost 5:57b06b4b47c6 83 // *********************
defrost 5:57b06b4b47c6 84 // * Protected variables: *
defrost 5:57b06b4b47c6 85 // *********************
defrost 5:57b06b4b47c6 86
epgmdm 11:87ab310924f0 87 int pipe; /**< The pipe on which the data was received */
epgmdm 11:87ab310924f0 88 int width; /**< The number of bytes of received data */
epgmdm 11:87ab310924f0 89
epgmdm 11:87ab310924f0 90 char * sdBuffer;
epgmdm 11:87ab310924f0 91 long long baseAddr;
epgmdm 11:87ab310924f0 92 long long utilityAddr;
epgmdm 11:87ab310924f0 93 char *timeValue; /**< String of time, see intOneSecond() */
epgmdm 11:87ab310924f0 94 volatile time_t now, lastRxTme;
defrost 5:57b06b4b47c6 95
defrost 5:57b06b4b47c6 96 // *********************
defrost 5:57b06b4b47c6 97 // * Protected functions: *
defrost 5:57b06b4b47c6 98 // *********************
epgmdm 11:87ab310924f0 99 /**
epgmdm 11:87ab310924f0 100 * When the button is pressed print status
epgmdm 11:87ab310924f0 101 */
epgmdm 11:87ab310924f0 102 void intButton() ;
epgmdm 11:87ab310924f0 103 /**
epgmdm 11:87ab310924f0 104 * set flag for 1 second interrupts
epgmdm 11:87ab310924f0 105 */
epgmdm 11:87ab310924f0 106 void intOneSecond();
epgmdm 11:87ab310924f0 107 /**
epgmdm 11:87ab310924f0 108 * Updates time string
epgmdm 11:87ab310924f0 109 */
epgmdm 11:87ab310924f0 110 void doOneSecond();
epgmdm 11:87ab310924f0 111 /**
epgmdm 11:87ab310924f0 112 * Responds to the received signals from HMI
epgmdm 11:87ab310924f0 113 */
epgmdm 11:87ab310924f0 114 void doNrf();
epgmdm 11:87ab310924f0 115 /**
epgmdm 11:87ab310924f0 116 * called when the nrf creates an interrupt.
epgmdm 11:87ab310924f0 117 *
epgmdm 11:87ab310924f0 118 */
epgmdm 11:87ab310924f0 119 void intNrf();
epgmdm 11:87ab310924f0 120
epgmdm 11:87ab310924f0 121 /**
epgmdm 11:87ab310924f0 122 * Cleans the receiver
epgmdm 11:87ab310924f0 123 */
epgmdm 11:87ab310924f0 124 void intRxClean();
epgmdm 11:87ab310924f0 125
epgmdm 11:87ab310924f0 126 /**
epgmdm 11:87ab310924f0 127 * Turns the Husker on
epgmdm 11:87ab310924f0 128 */
epgmdm 11:87ab310924f0 129 void turnHuskerOn(int on);
epgmdm 11:87ab310924f0 130
epgmdm 11:87ab310924f0 131
epgmdm 11:87ab310924f0 132 /**
epgmdm 11:87ab310924f0 133 * Turns the Incubator on
epgmdm 11:87ab310924f0 134 */
epgmdm 11:87ab310924f0 135 void turnIncubatorOn(int on);
epgmdm 11:87ab310924f0 136 /**
epgmdm 11:87ab310924f0 137 * Turns the posho on
epgmdm 11:87ab310924f0 138 */
epgmdm 11:87ab310924f0 139 void turnPoshoOn(int on);
defrost 5:57b06b4b47c6 140
defrost 5:57b06b4b47c6 141 };
defrost 5:57b06b4b47c6 142
defrost 5:57b06b4b47c6 143
defrost 5:57b06b4b47c6 144 #endif