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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/* Copyright (c) 2003-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
//****************************************************************************
//
// .NAME
// SignalLoggerManager - Handle signal loggers
//
//****************************************************************************
#ifndef SignalLoggerManager_H
#define SignalLoggerManager_H
#include <kernel_types.h>
#include <BlockNumbers.h>
#include <TransporterDefinitions.hpp>
class SignalLoggerManager
{
public:
SignalLoggerManager();
virtual ~SignalLoggerManager();
/**
* Sets output
* @Returns old output stream
*/
FILE * setOutputStream(FILE * output);
/**
* Gets current output
*/
FILE * getOutputStream() const;
void flushSignalLog();
/**
* For direct signals
* @See also SimulatedBlock EXECUTE_DIRECT
*/
void executeDirect(const SignalHeader&,
Uint8 prio, const Uint32 * theData, Uint32 node);
/**
* For input signals
*/
void executeSignal(const SignalHeader&, Uint8 prio,
const Uint32 * theData, Uint32 node,
const SegmentedSectionPtr ptr[3], Uint32 secs);
void executeSignal(const SignalHeader&, Uint8 prio,
const Uint32 * theData, Uint32 node,
const LinearSectionPtr ptr[3], Uint32 secs);
/**
* For output signals
*/
void sendSignal(const SignalHeader&, Uint8 prio,
const Uint32 * theData, Uint32 node,
const SegmentedSectionPtr ptr[3], Uint32 secs);
void sendSignal(const SignalHeader&, Uint8 prio,
const Uint32 * theData, Uint32 node,
const LinearSectionPtr ptr[3], Uint32 secs);
/**
* For output signals
*/
void sendSignalWithDelay(Uint32 delayInMilliSeconds,
const SignalHeader&,
Uint8 prio, const Uint32 * data, Uint32 node,
const SegmentedSectionPtr ptr[3], Uint32 secs);
/**
* Generic messages in the signal log
*/
void log(BlockNumber bno, const char * msg, ...);
/**
* LogModes
*/
enum LogMode {
LogOff = 0,
LogIn = 1,
LogOut = 2,
LogInOut = 3
};
/**
* Returns no of loggers affected
*/
int log(LogMode logMode, const char * params);
int logOn(bool allBlocks, BlockNumber bno, LogMode logMode);
int logOff(bool allBlocks, BlockNumber bno, LogMode logMode);
int logToggle(bool allBlocks, BlockNumber bno, LogMode logMode);
void setTrace(unsigned long trace);
unsigned long getTrace() const;
void setOwnNodeId(int nodeId);
void setLogDistributed(bool val);
/**
* Print header
*/
static void printSignalHeader(FILE * output,
const SignalHeader & sh,
Uint8 prio,
Uint32 node,
bool printReceiversSignalId);
/**
* Function for printing the Signal Data
*/
static void printSignalData(FILE * out,
const SignalHeader & sh, const Uint32 *);
/**
* Print linear section.
*/
static void printLinearSection(FILE * output,
const SignalHeader & sh,
const LinearSectionPtr ptr[3],
unsigned i);
/**
* Print segmented section.
*/
static void printSegmentedSection(FILE * output,
const SignalHeader & sh,
const SegmentedSectionPtr ptr[3],
unsigned i);
/**
* Print data word in hex. Adds line break before the word
* when pos > 0 && pos % 7 == 0. Increments pos.
*/
static void printDataWord(FILE * output, Uint32 & pos, const Uint32 data);
private:
bool m_logDistributed;
Uint32 m_ownNodeId;
FILE * outputStream;
int log(int cmd, BlockNumber bno, LogMode logMode);
Uint32 traceId;
Uint8 logModes[NO_OF_BLOCKS];
inline bool
logMatch(BlockNumber bno, LogMode mask)
{
// avoid addressing outside logModes
return
bno < MIN_BLOCK_NO || bno > MAX_BLOCK_NO ||
(logModes[bno-MIN_BLOCK_NO] & mask);
}
};
#endif // SignalLoggerManager_H
|