/******************************************************************************
 *
 *   This file is part of SC1 - Studer Communication driver 1, by Sven Ruin
 *   and Anders Andersson.
 *
 *   Copyright (C) 2010-2019  TEROC AB.
 *
 *   SC1 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 3 of the License, or
 *   (at your option) any later version.
 *
 *   SC1 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 SC1.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   Note that SC1 depends on other software, with different licensing
 *   conditions.
 *
 *   We are thankful to Echelon/Adesto, Studer Innotec and others, who have
 *   provided helpful examples and support.
 *
 *   For more information, contact Sven Ruin, sven.ruin@teroc.se
 *   
 *   Revision history:
 *   Ver 1.3 (2019-10-29) GNU General Public License, ++ operator, comments etc
 *   Ver 1.2 (2015-02-09) Changed to 1 req/s
 *   Ver 1.1 (2014-11-06) Corrected scaling of YD variables
 *
 *   SC1 is a FPM Driver intended to run on an i.LON SmartServer FT/PL 
 *   connected to Studer XCOM-232i (or RCC-02-32) with a serial communication 
 *   cable, with the following connections:
 *
 *   i.LON screw terminal        Studer side contact pin number
 *   23 (RXD)                    2
 *   24 (TXD)                    3
 *   25 (GND)                    5
 *
 ******************************************************************************/

SC1 ver 1.3 is a Freely Programmable Module (FPM) Driver used for an i.LON 
SmartServer FT/PL to communicate with a Studer Xtender system. It has been 
created with the i.LON SmartServer 2.0 Programming Tools (based on Eclipse), 
which runs on a Windows computer, and tested on i.LON SmartServer 2.2.

To deploy this FPM Driver, upload the .drv file (found in the Release 4.03 
folder) using FTP to the root/modules/User/TEROC folder on the SmartServer and 
reboot the SmartServer. See "Deploying FPM Drivers" in the Programming Tools 
Users Guide. If the TEROC folder does not exist, it needs to be created (and 
can be given a different name than TEROC if you want).

The SmartServer needs to have FPM ability licensed, which if necessary can be 
activated afterwards. (On the SmartServer's web interface, go to the "Setup - 
System Info" page and scroll down to "FPM Licensed". Click on "Not Licensed" 
if that is shown, in order to find instructions for activation.)

See also
https://adesto.zendesk.com/hc/en-us/articles/202601204-i-LON-and-SmartServer-Troubleshooting-Tips-KB932- (regarding FTP etc)
and
https://adesto.zendesk.com/hc/en-us/articles/205082654-How-do-I-activate-SmartServer-IP-852-or-FPM-licenses-KB962- (regarding e.g. the directory for the license activation key, which is a .xml file)

The following variables are communicated by SC1:
nvoUbat (SNVT_volt) Battery voltage
nvoTbat (SNVT_temp) Battery temperature (no sensor = -1C)
nvoIbat (SNVT_amp) Battery charge current
nvoPhase (SNVT_count) Battery cycle phase (0:Invalid value 1:Bulk 2:Absorpt. 3:Equalise 4:Floating 5:R.float. 6:Per.abs. 7:Mixing 8:Forming)
nvoUin (SNVT_volt) Input voltage (AC)
nvoIin (SNVT_amp) Input current (AC)
nvoTransf (SNVT_switch) State of transfer relay
nvoUout (SNVT_volt) Output voltage (AC)
nvoIout (SNVT_amp) Output current (AC)
nvoMode (SNVT_count) Working mode of the inverter (0:Invalid value 1:Inverter 2:Charger 3:Boost 4:Injection)
nvoEACinYD (SNVT_elec_whr_f) Energy in of the previous day (AC)
nvoEACoutYD (SNVT_elec_whr_f) Energy out of the previous day (AC)
nvoCommOK (SNVT_switch) Communication with Studer OK

In case of communication error, default values will be used, for example 
nvoUbat = -32768 (-3276.8 V shown by SmartServer).
See source code in UFPTSC1.cpp for more information about default values etc.
