File: powercom.h

package info (click to toggle)
nut 2.8.4%2Breally-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,720 kB
  • sloc: ansic: 132,030; sh: 17,256; cpp: 12,566; makefile: 5,646; python: 1,114; perl: 856; xml: 47
file content (106 lines) | stat: -rw-r--r-- 3,390 bytes parent folder | download
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
/*
 * powercom.h - defines for the newpowercom.c driver
 *
 * Copyrights:
 * (C) 2002 Simon Rozman <simon@rozman.net>
 * (C) 1999  Peter Bieringer <pb@bieringer.de>
 *
 * 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef NUT_POWERCOM_H_SEEN
#define NUT_POWERCOM_H_SEEN 1

/* C-libary includes */
#include <sys/file.h>
#include <sys/stat.h>
#ifndef WIN32
#include <sys/ioctl.h>
#endif	/* !WIN32 */
#include <sys/types.h>

/* nut includes */
#include "serial.h"
#include "nut_stdint.h"
#include "timehead.h"


/* supported types */
struct type {
	const char    *name;
	unsigned char num_of_bytes_from_ups;

	struct method_of_flow_control {
		const char *name;
		void (*setup_flow_control)(void);
	} flowControl;

	struct validation_byte {
		unsigned int index_of_byte, required_value;
		/* An example might explain the intention better then prose.
		 * Suppose we want to validate the data with:
		 *     powercom_raw_data[5] == 0x80
		 * then we will set index_of_byte to 5U and required_value to
		 * 0x80U: { 5U, 0x80U }.
		 */
	} validation[3];
	/* The validation array is of length 3 because 3 is longest
	 * validation sequence for any type.
	 */

	/* Some UPSs must have a minutes and a seconds arguments for
	 * the COUNTER commands while others are known to work with the
	 * seconds argument alone.
	 */
	struct delay_for_power_kill {
		unsigned char delay[2];   /* { minutes, seconds } */
		unsigned char minutesShouldBeUsed;
		/* 'n' in case the minutes value, which is delay[0], should
		 * be skipped and not sent to the UPS.
		 */
	} shutdown_arguments;

	/* parameters to calculate input and output freq., one pair used for
	 * both input and output functions:
	 *  The pair [0],[1] defines parameters for 1/(A*x+B) to calculate freq.
	 *  from raw data 'x'.
	 */
	float         freq[2];

	/* parameters to calculate load %, two pairs for each type:
	 *  First pair [0],[1] defines the parameters for A*x+B to calculate load
	 *  from raw data when offline and the second pair [2],[3] is used when
	 *  online
	 */
	float         loadpct[4];

	/* parameters to calculate battery %, five parameters for each type:
	 *  First three params [0],[1],[2] defines the parameters for A*x+B*y+C to calculate
	 *  battery % (x is raw data, y is load %) when offline.
	 *  Fourth and fifth parameters [3],[4] are used to calculate D*x+E when online.
	 */
	float         battpct[5];

	/* parameters to calculate utility and output voltage, two pairs for
	 * each type:
	 *  First pair [0],[1] defines the parameters for A*x+B to calculate utility
	 *  from raw data when line voltage is >=220 and the second pair [2],[3]
	 *  is used otherwise.
	 */
	float         voltage[4];
};

#endif	/* NUT_POWERCOM_H_SEEN */