Committer:
Wimpie
Date:
Sun Apr 17 17:25:56 2011 +0000
Revision:
3:5ae3c983f241
Parent:
2:0306beaf5ff7
Child:
4:c16866ed9508

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wimpie 0:313c9e399e12 1 /*
Wimpie 0:313c9e399e12 2 Copyright (c) 2010 Wim De Roeve
Wimpie 0:313c9e399e12 3
Wimpie 0:313c9e399e12 4 Permission is hereby granted, free of charge, to any person obtaining a copy
Wimpie 0:313c9e399e12 5 of this software and associated documentation files (the "Software"), to deal
Wimpie 0:313c9e399e12 6 in the Software without restriction, including without limitation the rights
Wimpie 0:313c9e399e12 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Wimpie 0:313c9e399e12 8 copies of the Software, and to permit persons to whom the Software is
Wimpie 0:313c9e399e12 9 furnished to do so, subject to the following conditions:
Wimpie 0:313c9e399e12 10
Wimpie 0:313c9e399e12 11 The above copyright notice and this permission notice shall be included in
Wimpie 0:313c9e399e12 12 all copies or substantial portions of the Software.
Wimpie 0:313c9e399e12 13
Wimpie 0:313c9e399e12 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Wimpie 0:313c9e399e12 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Wimpie 0:313c9e399e12 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Wimpie 0:313c9e399e12 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Wimpie 0:313c9e399e12 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Wimpie 0:313c9e399e12 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Wimpie 0:313c9e399e12 20 THE SOFTWARE.
Wimpie 0:313c9e399e12 21 */
Wimpie 0:313c9e399e12 22
Wimpie 3:5ae3c983f241 23 #ifndef VBUS_H
Wimpie 3:5ae3c983f241 24 #define VBUS_H
Wimpie 3:5ae3c983f241 25
Wimpie 0:313c9e399e12 26 #define Sync 0xAA // Synchronisation bytes
Wimpie 0:313c9e399e12 27 #define FLength 6 // Framelength
Wimpie 0:313c9e399e12 28 #define FOffset 10 // Offset start of Frames
Wimpie 0:313c9e399e12 29 #define FSeptet 4 // Septet byte in Frame
Wimpie 0:313c9e399e12 30 #define ResolAddress 0x3271 // Address of the controller
Wimpie 0:313c9e399e12 31 #define SENSORNOTCONNECTED 8888
Wimpie 0:313c9e399e12 32
Wimpie 0:313c9e399e12 33 #include "mbed.h"
Wimpie 0:313c9e399e12 34
Wimpie 0:313c9e399e12 35 /** @defgroup API The VBus API */
Wimpie 0:313c9e399e12 36
Wimpie 0:313c9e399e12 37 /** VBus module
Wimpie 0:313c9e399e12 38 * @author Wim De Roeve
Wimpie 0:313c9e399e12 39 *
Wimpie 0:313c9e399e12 40 * Example:
Wimpie 0:313c9e399e12 41 * @code
Wimpie 0:313c9e399e12 42 * #include "mbed.h"
Wimpie 0:313c9e399e12 43 * #include "VBus.h"
Wimpie 0:313c9e399e12 44 *
Wimpie 0:313c9e399e12 45 * Serial pc(USBTX, USBRX);
Wimpie 0:313c9e399e12 46 * VBus ResolBS(p9, p10);
Wimpie 0:313c9e399e12 47 *
Wimpie 0:313c9e399e12 48 * int main() {
Wimpie 0:313c9e399e12 49 *
Wimpie 2:0306beaf5ff7 50 * while(1){
Wimpie 0:313c9e399e12 51 * if (ResolBS.Read()) {
Wimpie 0:313c9e399e12 52 *
Wimpie 0:313c9e399e12 53 * pc.printf("T collector = %.1f\r\n",ResolBS.Sensor1_temp);
Wimpie 0:313c9e399e12 54 * pc.printf("T store = %.1f\r\n",ResolBS.Sensor2_temp);
Wimpie 0:313c9e399e12 55 * pc.printf("T3 = %.1f\r\n",ResolBS.Sensor3_temp);
Wimpie 0:313c9e399e12 56 * pc.printf("T4 = %.1f\r\n",ResolBS.Sensor4_temp);
Wimpie 0:313c9e399e12 57 * }
Wimpie 0:313c9e399e12 58 * }
Wimpie 0:313c9e399e12 59 * }
Wimpie 0:313c9e399e12 60 * @endcode
Wimpie 0:313c9e399e12 61 */
Wimpie 0:313c9e399e12 62
Wimpie 0:313c9e399e12 63 class VBus {
Wimpie 0:313c9e399e12 64 public:
Wimpie 0:313c9e399e12 65 //! VBus constructor.
Wimpie 0:313c9e399e12 66 /**
Wimpie 0:313c9e399e12 67 * The VBus constructor is used to initialise the VBus object.
Wimpie 0:313c9e399e12 68 *
Wimpie 0:313c9e399e12 69 * @param tx The TX pin the VBus is connected to p9, p13, p28
Wimpie 0:313c9e399e12 70 * @param rx The RX pin the GPS is connected to p10, p14, p27.
Wimpie 0:313c9e399e12 71 */
Wimpie 0:313c9e399e12 72
Wimpie 0:313c9e399e12 73 VBus(PinName tx, PinName rx);
Wimpie 0:313c9e399e12 74
Wimpie 0:313c9e399e12 75 uint16_t networkaddress;
Wimpie 0:313c9e399e12 76 float Sensor1_temp;
Wimpie 0:313c9e399e12 77 float Sensor2_temp;
Wimpie 0:313c9e399e12 78 float Sensor3_temp;
Wimpie 0:313c9e399e12 79 float Sensor4_temp;
Wimpie 0:313c9e399e12 80
Wimpie 3:5ae3c983f241 81 float Sensor1_temp_max;
Wimpie 3:5ae3c983f241 82 float Sensor2_temp_max;
Wimpie 3:5ae3c983f241 83 float Sensor3_temp_max;
Wimpie 3:5ae3c983f241 84 float Sensor4_temp_max;
Wimpie 3:5ae3c983f241 85
Wimpie 0:313c9e399e12 86 char PumpSpeed1; // in %
Wimpie 0:313c9e399e12 87 char PumpSpeed2; // in %
Wimpie 0:313c9e399e12 88 char RelaisMask;
Wimpie 0:313c9e399e12 89 char ErrorMask;
Wimpie 0:313c9e399e12 90 uint16_t SystemTime;
Wimpie 0:313c9e399e12 91 char System;
Wimpie 0:313c9e399e12 92 char OptionPostPulse;
Wimpie 0:313c9e399e12 93 char OptionThermostat;
Wimpie 0:313c9e399e12 94 char OptionWMZ;
Wimpie 0:313c9e399e12 95 uint16_t OperatingHoursRelais1;
Wimpie 0:313c9e399e12 96 uint16_t OperatingHoursRelais2;
Wimpie 3:5ae3c983f241 97 uint16_t OperatingHoursRelais1Today;
Wimpie 3:5ae3c983f241 98
Wimpie 0:313c9e399e12 99 void Init(int addr);
Wimpie 0:313c9e399e12 100 bool Read();
Wimpie 3:5ae3c983f241 101 void SaveToSDcard(char* datetime, char* date,char* dayfn);
Wimpie 3:5ae3c983f241 102 void SDcardAvailable(bool status);
Wimpie 3:5ae3c983f241 103 void ClearMax();
Wimpie 0:313c9e399e12 104
Wimpie 0:313c9e399e12 105 protected:
Wimpie 0:313c9e399e12 106 Serial _Serial;
Wimpie 0:313c9e399e12 107
Wimpie 0:313c9e399e12 108 private:
Wimpie 0:313c9e399e12 109
Wimpie 0:313c9e399e12 110 unsigned char Buffer[80];
Wimpie 0:313c9e399e12 111 volatile unsigned char Bufferlength;
Wimpie 0:313c9e399e12 112
Wimpie 0:313c9e399e12 113 unsigned int Destination_address ;
Wimpie 0:313c9e399e12 114 unsigned int Source_address;
Wimpie 0:313c9e399e12 115 unsigned char ProtocolVersion;
Wimpie 0:313c9e399e12 116 unsigned int Command ;
Wimpie 0:313c9e399e12 117 unsigned char Framecnt ;
Wimpie 0:313c9e399e12 118 unsigned char Septet ;
Wimpie 0:313c9e399e12 119 unsigned char Checksum ;
Wimpie 0:313c9e399e12 120
Wimpie 0:313c9e399e12 121 float m_timeout;
Wimpie 0:313c9e399e12 122 Timer m_timer;
Wimpie 0:313c9e399e12 123
Wimpie 3:5ae3c983f241 124 bool _sdcard;
Wimpie 3:5ae3c983f241 125 bool _all;
Wimpie 3:5ae3c983f241 126
Wimpie 0:313c9e399e12 127 void InjectSeptet(unsigned char *Buffer, int Offset, int Length);
Wimpie 0:313c9e399e12 128 void FrameOutput (void);
Wimpie 0:313c9e399e12 129 void make_Header (unsigned int DAdr,unsigned int SAdr,unsigned char Ver,unsigned int Cmd,unsigned char AFrames);
Wimpie 0:313c9e399e12 130
Wimpie 0:313c9e399e12 131 };
Wimpie 3:5ae3c983f241 132 #endif
Wimpie 0:313c9e399e12 133
Wimpie 0:313c9e399e12 134
Wimpie 0:313c9e399e12 135
Wimpie 0:313c9e399e12 136
Wimpie 0:313c9e399e12 137