Updates
This commit is contained in:
33
Dockerfile.dpwr
Normal file
33
Dockerfile.dpwr
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# start from base
|
||||||
|
FROM debian:latest
|
||||||
|
|
||||||
|
LABEL maintainer="Philip Smart <philip.smart@net2net.org>"
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get -yqq update
|
||||||
|
RUN apt-get -yqq upgrade
|
||||||
|
RUN apt-get -yqq install procps build-essential perl
|
||||||
|
RUN apt-get -yqq install socat
|
||||||
|
RUN apt-get -yqq install cpanminus
|
||||||
|
|
||||||
|
# Bring in all perl packages.
|
||||||
|
RUN cpan App::cpanminus
|
||||||
|
RUN cpanm forks
|
||||||
|
RUN cpanm Switch
|
||||||
|
RUN cpanm CGI
|
||||||
|
RUN cpanm CGI::Session
|
||||||
|
RUN cpanm Device::SerialPort
|
||||||
|
|
||||||
|
# In case of manual (via bash) changes.
|
||||||
|
RUN apt-get -yqq install vim
|
||||||
|
|
||||||
|
# Copy dPWR
|
||||||
|
ADD --chown=www-data:www-data dPWR/. /usr/local/DPWR/
|
||||||
|
COPY --chown=www-data:www-data dPWR/etc/DPWR.cfg.docker /usr/local/DPWR/etc/DPWR.cfg
|
||||||
|
WORKDIR /usr/local/DPWR
|
||||||
|
|
||||||
|
# Expose the web-server port from the container.
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Start dPWR
|
||||||
|
CMD [ "bash", "etc/startDPWRinDocker" ]
|
||||||
26
Dockerfile.jdpwr
Normal file
26
Dockerfile.jdpwr
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# start from base
|
||||||
|
FROM debian:latest
|
||||||
|
|
||||||
|
LABEL maintainer="Philip Smart <philip.smart@net2net.org>"
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get -yqq update
|
||||||
|
RUN apt-get -yqq upgrade
|
||||||
|
RUN apt-get -yqq install procps
|
||||||
|
RUN apt-get -yqq install socat
|
||||||
|
RUN apt-get -yqq install default-jre
|
||||||
|
|
||||||
|
# In case of manual (via bash) changes.
|
||||||
|
RUN apt-get -yqq install vim
|
||||||
|
|
||||||
|
# Copy jDPWR
|
||||||
|
ADD --chown=www-data:www-data jDPWR/target/jDPWR-9.3.9.v20160517.jar /usr/local/jDPWR/jar/
|
||||||
|
COPY --chown=www-data:www-data jDPWR/jDPWR.cfg.docker /usr/local/jDPWR/jDPWR.cfg
|
||||||
|
COPY --chown=www-data:www-data jDPWR/jDPWR.cfg.default /usr/local/jDPWR/
|
||||||
|
WORKDIR /usr/local/jDPWR
|
||||||
|
|
||||||
|
# Expose the web-server port from the container.
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Start dPWR
|
||||||
|
CMD [ "java", "-jar", "jar/jDPWR-9.3.9.v20160517.jar" ]
|
||||||
@@ -325,7 +325,7 @@ sub htContent_AddBuf
|
|||||||
sub htContent_ExpandMacro
|
sub htContent_ExpandMacro
|
||||||
{
|
{
|
||||||
my ($http, $str, $includeFile, $activeMenu, $activeSubMenu) = @_;
|
my ($http, $str, $includeFile, $activeMenu, $activeSubMenu) = @_;
|
||||||
my ($allPorts, $boardPage, $dynstr, $level, @macro, $returnHTML) = (0, "", "", 0, (), "");
|
my ($allPorts, $boardPage, $dynstr, $level, $returnHTML, @macro) = (0, "", "", 0, "", ());
|
||||||
|
|
||||||
# Split macro up into it's components.
|
# Split macro up into it's components.
|
||||||
#
|
#
|
||||||
@@ -338,7 +338,7 @@ sub htContent_ExpandMacro
|
|||||||
or die "Cannot open HTML Include File:$http->{PARAMS}->{'HTTP_DOC_PATH'}/inc/$includeFile";
|
or die "Cannot open HTML Include File:$http->{PARAMS}->{'HTTP_DOC_PATH'}/inc/$includeFile";
|
||||||
while(my $incLine=<HTML_HDL>)
|
while(my $incLine=<HTML_HDL>)
|
||||||
{
|
{
|
||||||
$returnHTML = $returnHTML . $incLine;
|
$returnHTML = ($returnHTML eq "" ? $incLine : $returnHTML . $incLine);
|
||||||
}
|
}
|
||||||
close(HTML_HDL);
|
close(HTML_HDL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1550,7 +1550,7 @@ CONFIG Linux.U3SHIELD.v2dev
|
|||||||
DEVICE_1_PORT_MIN = 16
|
DEVICE_1_PORT_MIN = 16
|
||||||
DEVICE_1_PORT_MAX = 35
|
DEVICE_1_PORT_MAX = 35
|
||||||
DEVICE_1_BASE_ADDR = 0
|
DEVICE_1_BASE_ADDR = 0
|
||||||
DEVICE_1_UART = "/dev/tty5"
|
DEVICE_1_UART = "/dev/vcom0"
|
||||||
DEVICE_1_UART_BAUD = 115200
|
DEVICE_1_UART_BAUD = 115200
|
||||||
DEVICE_1_UART_DATABITS = 8
|
DEVICE_1_UART_DATABITS = 8
|
||||||
DEVICE_1_UART_PARITY = "none"
|
DEVICE_1_UART_PARITY = "none"
|
||||||
@@ -3145,7 +3145,7 @@ CONFIG Linux.U3SHIELD.v2dev
|
|||||||
DEVICE_2_PORT_MIN = 36
|
DEVICE_2_PORT_MIN = 36
|
||||||
DEVICE_2_PORT_MAX = 55
|
DEVICE_2_PORT_MAX = 55
|
||||||
DEVICE_2_BASE_ADDR = 0
|
DEVICE_2_BASE_ADDR = 0
|
||||||
DEVICE_2_UART = "/dev/tty6"
|
DEVICE_2_UART = "/dev/vcom1"
|
||||||
DEVICE_2_UART_BAUD = 115200
|
DEVICE_2_UART_BAUD = 115200
|
||||||
DEVICE_2_UART_DATABITS = 8
|
DEVICE_2_UART_DATABITS = 8
|
||||||
DEVICE_2_UART_PARITY = "none"
|
DEVICE_2_UART_PARITY = "none"
|
||||||
@@ -6101,7 +6101,7 @@ CONFIG Linux.U3SHIELD.v1hw
|
|||||||
DEVICE_1_PORT_MIN = 16
|
DEVICE_1_PORT_MIN = 16
|
||||||
DEVICE_1_PORT_MAX = 35
|
DEVICE_1_PORT_MAX = 35
|
||||||
DEVICE_1_BASE_ADDR = 0
|
DEVICE_1_BASE_ADDR = 0
|
||||||
DEVICE_1_UART = "/dev/tty6"
|
DEVICE_1_UART = "/dev/vcom1"
|
||||||
DEVICE_1_UART_BAUD = 115200
|
DEVICE_1_UART_BAUD = 115200
|
||||||
DEVICE_1_UART_DATABITS = 8
|
DEVICE_1_UART_DATABITS = 8
|
||||||
DEVICE_1_UART_PARITY = "none"
|
DEVICE_1_UART_PARITY = "none"
|
||||||
|
|||||||
7689
dPWR/etc/DPWR.cfg.docker
Normal file
7689
dPWR/etc/DPWR.cfg.docker
Normal file
File diff suppressed because it is too large
Load Diff
@@ -39,10 +39,17 @@ fi
|
|||||||
. /etc/profile
|
. /etc/profile
|
||||||
. ${BASEDIR}/etc/${PACKAGE}.shc
|
. ${BASEDIR}/etc/${PACKAGE}.shc
|
||||||
|
|
||||||
cd $ETCDIR
|
# Create virtual ports as dPWR ATMEGA expects to communicate with a serial port. If needed you can connect
|
||||||
|
# to the serial port via the container port forwarding.
|
||||||
|
#for i in {0..4}
|
||||||
|
#do
|
||||||
|
# socat pty,link=/dev/vcom${i},raw tcp4-listen:1000${i} &
|
||||||
|
#done
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
# Call the killDPWR script to terminate running process.
|
# Call the killDPWR script to terminate running process.
|
||||||
#
|
#
|
||||||
|
cd $ETCDIR
|
||||||
echo "Killing dpwr"
|
echo "Killing dpwr"
|
||||||
$ETCDIR/killDPWR
|
$ETCDIR/killDPWR
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|||||||
61
dPWR/etc/startDPWRinDocker
Executable file
61
dPWR/etc/startDPWRinDocker
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#########################################################################################################
|
||||||
|
##
|
||||||
|
## Name: startDPWRinDocker
|
||||||
|
## Created: November 2019
|
||||||
|
## Author(s): Philip Smart
|
||||||
|
## Description: A modified shell script to start the dPWR controller within a docker container.
|
||||||
|
##
|
||||||
|
## Credits:
|
||||||
|
## Copyright: (c) 2015-2019 Philip Smart <philip.smart@net2net.org>
|
||||||
|
##
|
||||||
|
## History: September 2015 - Initial module written.
|
||||||
|
## November 2019 - Adapted for docker.
|
||||||
|
##
|
||||||
|
#########################################################################################################
|
||||||
|
## This source file 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.
|
||||||
|
##
|
||||||
|
## This source file 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
#########################################################################################################
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# start script for the DPWR server
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
export SYSTEM=`uname`
|
||||||
|
export PACKAGE=DPWR
|
||||||
|
if [ "${SYSTEM}" = "Linux" ]; then
|
||||||
|
export BASEDIR=/usr/local/${PACKAGE}
|
||||||
|
else
|
||||||
|
export BASEDIR=/usr/local/${PACKAGE}
|
||||||
|
fi
|
||||||
|
. /etc/profile
|
||||||
|
. ${BASEDIR}/etc/${PACKAGE}.shc
|
||||||
|
|
||||||
|
# Create virtual ports as dPWR ATMEGA expects to communicate with a serial port. If needed you can connect
|
||||||
|
# to the serial port via the container port forwarding.
|
||||||
|
for i in {0..4}
|
||||||
|
do
|
||||||
|
socat pty,link=/dev/vcom${i},raw tcp4-listen:1000${i} &
|
||||||
|
done
|
||||||
|
|
||||||
|
# Ok, launch the program without spawning, exit means exit container so the original script
|
||||||
|
# could not be used in the container.
|
||||||
|
cd $ETCDIR
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
COMMAND="${BINDIR}/dpwr $@"
|
||||||
|
|
||||||
|
echo "Starting $COMMAND $*"
|
||||||
|
${BASEDIR}/etc/forever $COMMAND $*
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
echo "Done."
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
I needed a web based power controller to remotely control a large number of devices, Mains (230VAC) and low level DC voltages as well as read remote value such as switch settings. I looked at the market and there wasn't really anything suitable within an acceptable price range (B2B equipment was in the multi-thousand GBP price bracket). I didn't want to design and fabricate a dedicated circuit board so I sifted through my parts bin and used what I found and thus was born the dPWR Controller.
|
I needed a web based power controller to remotely control a large number of devices, Mains (230VAC) and low level DC voltages as well as read remote values such as switch settings or power states. I looked at the market and there wasn't really anything suitable within an acceptable price range (B2B equipment was in the multi-thousand GBP price bracket). I didn't want to design and fabricate a dedicated circuit board so I sifted through my parts bin and used what I found and thus was born the dPWR Controller.
|
||||||
|
|
||||||
I had a hardkernel.org Odroid (a Raspberry Pi type dev board) and U3 Shield along with some relay & thyristor switching boards and a few IO Expander chips and ATMega devices. I decided to base dPWR on a cobbling of these parts with the foresight of adding additional components as needed. In terms of software, the Linux operating system stood as the base platform rather than an embedded on metal application as the Odroid was sufficiently powerful, low power and made development that much easier.
|
I had a hardkernel.org Odroid U3 (a Raspberry Pi type dev board) and U3 Shield along with some relay & thyristor switching boards and a few IO Expander chips and ATMega devices. I decided to base dPWR on a cobbling of these parts with the foresight of adding additional components as needed. In terms of software, the Linux operating system stood as the base platform rather than an embedded on metal application as the Odroid was sufficiently powerful, low power and made development that much easier.
|
||||||
|
|
||||||
Having limited time I discounted C/C++ as it takes considerably longer to develop in these languages especially as performance wasn't a consideration, this left Java, Python and Perl. Having just finished an application for a client in Perl it just seemed a natural choice (even though it is a scripting language primarily developed for reporting but was incredibly rich in it's eco system).
|
Having limited time I discounted C/C++ as it takes considerably longer to develop in these languages especially as performance wasn't a consideration, this left Java, Python and Perl. Having just finished an application for a client in Perl it just seemed a natural choice (even though it is a scripting language primarily developed for reporting but was incredibly rich in it's eco system).
|
||||||
|
|
||||||
@@ -13,86 +13,228 @@ The functionality requirements for dPWR where:-
|
|||||||
|
|
||||||
The above was developed and has been reliably in service for the last 4 years. I recently removed the dPWR hardware to service it when the Corsair power supplies gave up the ghost and took the photos below.
|
The above was developed and has been reliably in service for the last 4 years. I recently removed the dPWR hardware to service it when the Corsair power supplies gave up the ghost and took the photos below.
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
The NC800 Ethernet based board, I worked on the module to control it but never actually used it in production.
|
|
||||||

|
|
||||||
|
|
||||||
I'm releasing the software into the public domain as I believe it can be (or parts of it) used in its current form to build a bespoke digital power controller or its web interface used for other projects.
|
I'm releasing the software into the public domain as I believe it can be (or parts of it) used in its current form to build a bespoke digital power controller or its web interface used for other projects.
|
||||||
|
|
||||||
The schematics for the dPWR hardware will need to be re-captured as they were all paper based.
|
The schematics for the dPWR hardware will need to be re-captured as they were all paper based.
|
||||||
|
|
||||||
|
## Evaluate with Docker
|
||||||
|
|
||||||
|
To evaluate dPWR, the easiest method is to create a docker image and run.
|
||||||
|
|
||||||
|
1. Clone the repository and build the docker image.
|
||||||
|
|
||||||
|
````bash
|
||||||
|
cd ~
|
||||||
|
mkdir temp
|
||||||
|
git clone https://github.com/pdsmart/dPWR.git
|
||||||
|
cd DPWR
|
||||||
|
docker build -f Dockerfile.dpwr -t dpwr .
|
||||||
|
````
|
||||||
|
|
||||||
|
2. Run the image mapping port 8080 to whichever port you want to use.
|
||||||
|
|
||||||
|
````bash
|
||||||
|
docker run --rm -p 8082:8080 --name dpwr dpwr
|
||||||
|
````
|
||||||
|
3. Open a web browser and go to http://localhost:8082
|
||||||
|
|
||||||
|
4. Login with the credentials
|
||||||
|
````
|
||||||
|
User: root
|
||||||
|
Password: 0000
|
||||||
|
````
|
||||||
|
|
||||||
|
5. Stop the application
|
||||||
|
|
||||||
|
````
|
||||||
|
docker stop dpwr
|
||||||
|
````
|
||||||
|
|
||||||
## dPWR Installation
|
## dPWR Installation
|
||||||
|
|
||||||
1) Setup of Linux onto a development board, Odroid as an example.
|
The section below assumes you are installing Debian or one of its derivatives, substitute relevant **yum** commands for Red Hat based linux versions.
|
||||||
|
|
||||||
2) Installing Perl and CPAN libraries: forks, CGI, CGI::Session, Device:SerialPort
|
1. Install Linux onto your development board Flash, SD or eMMC.
|
||||||
|
2. Clone the repository into a local temporary directory, install into /usr/local and set the ownership.
|
||||||
|
|
||||||
3) Installing DPWR and configuring.
|
```
|
||||||
|
cd /
|
||||||
|
git clone https://github.com/pdsmart/dPWR.git
|
||||||
|
cd DPWR
|
||||||
|
cp -r dPWR/* /usr/local/DPWR/
|
||||||
|
chown -R www-data:www-data /usr/local/DPWR
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Ensure all updates are applied:
|
||||||
|
|
||||||
|
```
|
||||||
|
apt-get update
|
||||||
|
apt-get upgrade
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Install required linux packages (Perl needs the build environment to compile its packages, you could locate the packages and install manually to avoid installing the build environment).
|
||||||
|
|
||||||
|
```
|
||||||
|
apt-get install procps build-essential perl socat cpanminus vim
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Install required Perl packages.
|
||||||
|
|
||||||
|
```
|
||||||
|
cpanm forks Switch CGI CGI::Session Device::SerialPort
|
||||||
|
```
|
||||||
|
|
||||||
|
6. If you have no serial ports on the development board (either physical or USB) then install socat virtual tty's to prevent selection of an ATMEGA328P device stopping the dPWR application.
|
||||||
|
|
||||||
|
```
|
||||||
|
# Create virtual ports as dPWR ATMEGA expects to communicate with a serial port. If needed you can connect
|
||||||
|
# to the serial port via the container port forwarding.
|
||||||
|
for i in {0..4}
|
||||||
|
do
|
||||||
|
socat pty,link=/dev/vcom${i},raw tcp4-listen:1000${i} &
|
||||||
|
done
|
||||||
|
|
||||||
|
# The above will be lost when the dev board is rebooted. If you want virtual ports to be permanently present when running dPWR, edit the script /usr/local/DPWR/etc/startDPWR and uncomment the lines which are identical to the above code block.
|
||||||
|
```
|
||||||
|
7. Edit the configuration file, /usr/local/DPWR/etc/DPWR.cfg locate the 'HTTP Server configuration' block as below and set the values beginning 'your':-
|
||||||
|
|
||||||
|
```
|
||||||
|
# HTTP Server configuration parameters.
|
||||||
|
#
|
||||||
|
HTTP_SERVER_HOST = "<your IP Address>"
|
||||||
|
HTTP_SERVER_PORT = <your Port Number>
|
||||||
|
HTTP_DOC_PATH = "/usr/local/DPWR/htdocs"
|
||||||
|
HTTP_LOGFILE = "/usr/local/DPWR/log/dpwr_http.log"
|
||||||
|
HTTP_PASSWORD = "0000"
|
||||||
|
HTTP_MAX_RETRIES = 3
|
||||||
|
HTTP_SESSION_TIMEOUT = 600
|
||||||
|
```
|
||||||
|
If you have serial ports on your development board then locate the following and change to actual device names from your board otherwise ensure the steps in 6 are in.
|
||||||
|
|
||||||
|
```
|
||||||
|
DEVICE_1_UART = "/dev/<your serial 1 device>"
|
||||||
|
DEVICE_2_UART = "/dev/<your serial 2 device>"
|
||||||
|
```
|
||||||
|
|
||||||
|
NB. You will notice 2 CONFIG blocks in the configuration file, the 'PRODUCT v2dev' keyword indicates which block to use. You can make as many of these blocks as you want, but only one can be active and that is indicated by the PRODUCT keyword.
|
||||||
|
|
||||||
|
8. Start the dPWR application.
|
||||||
|
|
||||||
|
```
|
||||||
|
cd /usr/local/DPWR/bin
|
||||||
|
./startDPWR
|
||||||
|
```
|
||||||
|
|
||||||
|
Check for error messages being output and correct, ie. Cannot open UART means there is an issue with the UART you set in 7, check it and if necessary revert to 6 until your physical serial ports work.
|
||||||
|
|
||||||
|
9. Verify it is working by opening a web browser on your network and connecting to http://\<IP>:\<Port> as set in 7 above.
|
||||||
|
|
||||||
|
|
||||||
## dPWR Web Interface
|
## dPWR Web Interface
|
||||||
|
|
||||||

|
A comprehensive web interface was developed in perl using configuration files and pages as much as possible. The following images show the base screens of the web interface.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Login is via user/password. 4 users are pre-defined, each with varying privileges.
|
||||||
|
|
||||||

|

|
||||||
|
<br>The home screen - blank - but easy enough to add status or other required data/instructions.
|
||||||
|
|
||||||

|

|
||||||
|
<br>The primary output control screen. Each port which is enabled and configured for output is display along with a description and an on/off switch. Simple enough to change a controlled device state. If more than one user is using the system, ticking Auto Refresh will update this view should another user change a switch.
|
||||||
|
|
||||||

|

|
||||||
|
<br>The primary input status screen. Each port which is enabled and configured for input is displayed along with its current value in the form of an on/off switch. Ticking Auto Refresh will periodically (configurable) re-read the device and display the status.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Setup Devices screen. Here you can add a device and set its configuration data. Enabled devices have there ports assigned to the global pool.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Setup Port screen. Here you can enable/disable a port and configure its settings.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Port Timers screen. Here you can setup output ports to run on a schedule, there are 8 timers per port.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Port change on Ping Activity screen. Here you can configure a port to be changed according to a successful network ping. ie. If a port is controlling a router and a ping cannot be established after the set times, it will automatically power down the router and bring it back up.
|
||||||
|
|
||||||

|

|
||||||
|
<br>The following screens allow a user to see the status of the dPWR hardware.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
<br>DDNS Setup screen. This allows you to configure an automated Dynamic DNS update. If the dPWR is behind a dynamic IP address which changes, using this option can update a Dynamic DNS hostname with the current IP so that you can always contact the dPWR.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Email setup screen. This allows you to configure an email alert when a state change occurs, ie. a pinger fails and auto restarts a device.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Change the current user password screen.
|
||||||
|
|
||||||

|

|
||||||
|
<br>Time setup screen. This allows you to enter the current date and time (required if using timers) either manually or via an NTP service.
|
||||||
|
|
||||||
|

|
||||||
|
<br>dPWR configuration parameters setup screen. Change specific dPWR runtime values.
|
||||||
|
<br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### To Do
|
||||||
|
1. Finish this document into a more usable installation guide.
|
||||||
|
|
||||||
#### To Do
|
|
||||||
1) Finish this document into a more usable installation guide.
|
|
||||||
|
|
||||||
|
### Images of the dPWR Hardware Components
|
||||||
|
|
||||||
|

|
||||||
|
<br>The Odroid U3 (running dPWR), shield and TCA6416A IC along with an 8 channel EX-06A Relay board used to switch low DC voltages.
|
||||||
|
|
||||||
|

|
||||||
|
<br>An opto-isolated mains switching (230vac) board using Thyristors and Relays with readback.
|
||||||
|
|
||||||
|

|
||||||
|
<br>A second EX-06A for low switching DC voltages.
|
||||||
|
|
||||||
|

|
||||||
|
<br>One of 2 Corsair 750W PSU's. The dPWR unit was housed in a loft which was not such an hospitable environment (cold in winter, very hot in summer) but they managed to last 4 years!
|
||||||
|
|
||||||
|

|
||||||
|
<br>The U3 Shield seperated from the Odroid-U3 dev board. [HardKernel](www.hardkernel.com) make some lovely development boards from low power to multi-processor using Samsung chipsets.
|
||||||
|
|
||||||
|

|
||||||
|
<br>The Nano ATMega328p from SainSmart. This module was used as an intelligent I/O expansion within dPWR albeit the 'intelligent' part was never really used. It was in my parts bin and proved reliable.
|
||||||
|
|
||||||
|

|
||||||
|
<br>A Sainsmart 16 Channel Relay board hooked up to the ATMega328p I/O expander. This board proved reliable for low and high voltage switching.
|
||||||
|
|
||||||
|

|
||||||
|
<br>A Sainsmart 16 channel relay board modified with an ESP8266 controller. This board never made it into production as it depended on a wifi connection being established with an access point in order to connect with the main dPWR U3 board. It basically worked but the wifi wasnt reliable enough.
|
||||||
|
|
||||||
|

|
||||||
|
<br>The NC800 Ethernet based board, I worked on the module to control it but never actually used it in production. This kind of board would be ideal for remote control if an ethernet link and PoE was available.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Where I have used or based any component on a 3rd parties design I have included the original authors copyright notice. All 3rd party software, to my knowledge, is open source and freely useable, if there is found to be any component with licensing restrictions, it will be removed from this repository and a suitable link/config provided.
|
Where I have used or based any component on a 3rd parties design I have included the original authors copyright notice within the headers or given due credit. All 3rd party software, to my knowledge and research, is open source and freely useable, if there is found to be any component with licensing restrictions, it will be removed from this repository and a suitable link/config provided.
|
||||||
|
|
||||||
|
|
||||||
## Licenses
|
## Licenses
|
||||||
|
|
||||||
This design, hardware and software, is licensed under the GNU Public Licence v3.
|
This design, hardware and software, is licensed under the GNU Public Licence v3.
|
||||||
|
|
||||||
|
### The Gnu Public License v3
|
||||||
|
The source and binary files in this project marked as GPL v3 are 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.
|
||||||
|
|
||||||
|
The source files are 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, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,21 +2,86 @@
|
|||||||
|
|
||||||
A follow up to the dPWR Perl based Power Controller, I started to convert it into a Java version using Jetty and Java Servlets, named it jDPWR, with the purpose to allow it's use on more platforms than the Perl based dPWR. During the conversion I got sidetracked with VHDL pushing this project out to a future date. I will eventually finish it off but it is a good starting place for anyone wanting to develop a java based controller.
|
A follow up to the dPWR Perl based Power Controller, I started to convert it into a Java version using Jetty and Java Servlets, named it jDPWR, with the purpose to allow it's use on more platforms than the Perl based dPWR. During the conversion I got sidetracked with VHDL pushing this project out to a future date. I will eventually finish it off but it is a good starting place for anyone wanting to develop a java based controller.
|
||||||
|
|
||||||
|
## Evaluate with Docker
|
||||||
|
|
||||||
|
To evaluate jDPWR, the easiest method is to create a docker image and run.
|
||||||
|
|
||||||
|
1. Clone the repository and build the docker image.
|
||||||
|
|
||||||
|
````bash
|
||||||
|
cd ~
|
||||||
|
mkdir temp
|
||||||
|
git clone https://github.com/pdsmart/dPWR.git
|
||||||
|
cd DPWR
|
||||||
|
docker build -f Dockerfile.jdpwr -t jdpwr .
|
||||||
|
````
|
||||||
|
|
||||||
|
2. Run the image mapping port 8080 to whichever port you want to use.
|
||||||
|
|
||||||
|
````bash
|
||||||
|
docker run --rm -p 8100:8080 --name jdpwr jdpwr
|
||||||
|
````
|
||||||
|
3. Open a web browser and go to http://localhost:8100
|
||||||
|
|
||||||
|
4. Stop the application
|
||||||
|
|
||||||
|
````
|
||||||
|
docker stop jdpwr
|
||||||
|
````
|
||||||
|
|
||||||
|
|
||||||
## jDPWR Installation
|
## jDPWR Installation
|
||||||
|
|
||||||
Assuming a Unix based OS:
|
The section below assumes you are installing Debian or one of its derivatives, substitute relevant **yum** commands for Red Hat based linux versions.
|
||||||
1. Clone the repository.
|
|
||||||
2. Install Maven.
|
As the development is not yet complete, the assumption is it will be developed, compiled and run in-situ.
|
||||||
3. Build the jar:<br>
|
|
||||||
cd \<project root directory>/jDPWR<br>
|
1. Install Linux onto your development board Flash, SD or eMMC.
|
||||||
mvn clean package<br>
|
2. Clone the repository into a local temporary directory, install into /usr/local and set the ownership.
|
||||||
4. Manually edit the JSON config file \<project root directory>/jDPWR.cfg<br>
|
|
||||||
Change http::serverHost to a valid IP for your machine.<br>
|
```
|
||||||
Change http::serverPort to a value suitable for your machine, ie: 8080<br>
|
cd ~
|
||||||
5. Run the application<br>
|
git clone https://github.com/pdsmart/dPWR.git
|
||||||
cd target<br>
|
cd DPWR
|
||||||
java -jar jDPWR-\<version>.jar<br>
|
ln -s ~/DPWR/jDPWR /usr/local/jDPWR
|
||||||
6. Open a web browser and enter http://\<your IP>:\<your Port>
|
chown -R www-data:www-data ~/DPWR/jDPWR
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Ensure all updates are applied:
|
||||||
|
|
||||||
|
```
|
||||||
|
apt-get update
|
||||||
|
apt-get upgrade
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Install neccessary packages:
|
||||||
|
|
||||||
|
```
|
||||||
|
apt-get -yqq install procps socat default-jdk maven vim
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Build the jar:
|
||||||
|
|
||||||
|
````bash
|
||||||
|
cd ~/DPWR/jDPWR
|
||||||
|
mvn clean package
|
||||||
|
````
|
||||||
|
6. Manually edit the JSON config file ~/DPWR/jDPWR/jDPWR.cfg
|
||||||
|
|
||||||
|
````bash
|
||||||
|
Change http::serverHost to a valid IP for your machine.
|
||||||
|
Change http::serverPort to a value suitable for your machine, ie: 8080
|
||||||
|
````
|
||||||
|
7. Run the application
|
||||||
|
|
||||||
|
````bash
|
||||||
|
cd /usr/local/jDPWR/target
|
||||||
|
java -jar jDPWR-\<version>.jar
|
||||||
|
````
|
||||||
|
8. Open a web browser and enter http://\<your IP>:\<your Port>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## jDPWR Web Interface
|
## jDPWR Web Interface
|
||||||
|
|
||||||
|
|||||||
1062
jDPWR/jDPWR.cfg.docker
Normal file
1062
jDPWR/jDPWR.cfg.docker
Normal file
File diff suppressed because it is too large
Load Diff
@@ -86,8 +86,8 @@ public class jDPWR
|
|||||||
//
|
//
|
||||||
// Constants.
|
// Constants.
|
||||||
//
|
//
|
||||||
private static final String CONFIG_FILE = "../jDPWR.cfg";
|
private static final String CONFIG_FILE = "jDPWR.cfg";
|
||||||
private static final String DEFAULT_CONFIG_FILE = "../jDPWR.cfg.default";
|
private static final String DEFAULT_CONFIG_FILE = "jDPWR.cfg.default";
|
||||||
|
|
||||||
// Maxims.
|
// Maxims.
|
||||||
//
|
//
|
||||||
@@ -109,8 +109,13 @@ public class jDPWR
|
|||||||
//
|
//
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Boolean readDefault = false;
|
Boolean readDefault = false;
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
dpwr = mapper.readValue(new File(CONFIG_FILE), DPWRServlet.class);
|
dpwr = mapper.readValue(new File(CONFIG_FILE), DPWRServlet.class);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
dpwr = mapper.readValue(new File("../" + CONFIG_FILE), DPWRServlet.class);
|
||||||
|
}
|
||||||
LOG.info("Loaded configuration: " + CONFIG_FILE);
|
LOG.info("Loaded configuration: " + CONFIG_FILE);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e) {
|
catch (JsonGenerationException e) {
|
||||||
@@ -134,8 +139,13 @@ public class jDPWR
|
|||||||
if(readDefault)
|
if(readDefault)
|
||||||
{
|
{
|
||||||
System.out.println("Reading default configuration: " + DEFAULT_CONFIG_FILE);
|
System.out.println("Reading default configuration: " + DEFAULT_CONFIG_FILE);
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
dpwr = mapper.readValue(new File(DEFAULT_CONFIG_FILE), DPWRServlet.class);
|
dpwr = mapper.readValue(new File(DEFAULT_CONFIG_FILE), DPWRServlet.class);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
dpwr = mapper.readValue(new File("../" + DEFAULT_CONFIG_FILE), DPWRServlet.class);
|
||||||
|
}
|
||||||
LOG.info("Loaded default configuration: " + DEFAULT_CONFIG_FILE);
|
LOG.info("Loaded default configuration: " + DEFAULT_CONFIG_FILE);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user