Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from qurm #9

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
__pycache__
.coverage
__testdb__*
.idea/
smadata_venv/
notes.txt

110 changes: 110 additions & 0 deletions doc/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Python SMAData2 Database

This describes the database classes and table structure.

### base.py
Uses abstract base classes (Python `abc`) to define an interface (class and set of methods) that are implemented by `mock.py` and `sqllite.py`. These deal with the physical sqllite database, or a mock database (Python ``set``) for testing purposes.

### Table: generation
Stores readings
```sql
CREATE TABLE generation (
inverter_serial INTEGER NOT NULL,
timestamp INTEGER NOT NULL,
sample_type INTEGER CHECK (sample_type = 0 OR
sample_type = 1 OR
sample_type = 2),
total_yield INTEGER,
PRIMARY KEY (
inverter_serial,
timestamp,
sample_type
)
);
```
See base.py for further details.

```pythonstub
# Ad hoc samples, externally controlled
SAMPLE_ADHOC = 0
# Inverter recorded high(ish) frequency samples
SAMPLE_INV_FAST = 1
# Inverted recorded daily samples
SAMPLE_INV_DAILY = 2
```

### Table: pvoutput
Stores records of uploads to PVOutput.org
```sql
CREATE TABLE pvoutput (
sid STRING,
last_datetime_uploaded INTEGER
);
```



### Table: EventData
Stores events as reported by the SMA device.
These include setting time, error conditions.
```sql
CREATE TABLE EventData (
EntryID INT (4),
TimeStamp DATETIME NOT NULL,
Serial INT (4) NOT NULL,
SusyID INT (2),
EventCode INT (4),
EventType VARCHAR (32),
Category VARCHAR (32),
EventGroup VARCHAR (32),
Tag VARCHAR (200),
OldValue VARCHAR (32),
NewValue VARCHAR (32),
UserGroup VARCHAR (10),
PRIMARY KEY (
Serial,
EntryID
)
);
```

### Table: SpotData
Stores spot readings from the SMA device.
These include V, I for 3 phases , Grid Frequency, Temperature, BT signal.
Readings have any scale factor applied.
Some redundant fields
```sql
CREATE TABLE SpotData (
TimeStamp DATETIME NOT NULL,
Serial INT (4) NOT NULL,
Pdc1 INT,
Pdc2 INT,
Idc1 FLOAT,
Idc2 FLOAT,
Udc1 FLOAT,
Udc2 FLOAT,
Pac1 INT,
Pac2 INT,
Pac3 INT,
Iac1 FLOAT,
Iac2 FLOAT,
Iac3 FLOAT,
Uac1 FLOAT,
Uac2 FLOAT,
Uac3 FLOAT,
EToday INT (8),
ETotal INT (8),
Frequency FLOAT,
OperatingTime DOUBLE,
FeedInTime DOUBLE,
BT_Signal FLOAT,
Status VARCHAR (10),
GridRelay VARCHAR (10),
Temperature FLOAT,
PRIMARY KEY (
TimeStamp,
Serial
)
);

```
8 changes: 6 additions & 2 deletions doc/example.smadata2.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
"inverters": [{
"name": "Inverter 1",
"bluetooth": "00:80:25:xx:yy:zz",
"serial": "2130012345"
"serial": "2130012345",
"start-time": "2019-01-17",
"password": "0000"
}, {
"name": "Inverter 2",
"bluetooth": "00:80:25:pp:qq:rr",
"serial": "2130012346"
"serial": "2130012346",
"start-time": "2019-01-24",
"password": "1234"
}]
}]
}
Loading