This demonstrates the process of communicating through ethernet to a SEL-2431 Voltage Regulator Control Panel using SEL Fast Message. Basic device commands and data cna be requested and displayed over a connected serial port. This is a basic version and full testing and documentation has yet to be completed.

Dependencies:   BufferedSerial analogAverager voltageRegulator netStatReg analogMinMax CounterMinMax

Files at this revision

API Documentation at this revision

Comitter:
masterkookus
Date:
Fri Oct 11 16:32:45 2019 +0000
Parent:
14:3d437acb92e3
Child:
16:018bed9abe89
Commit message:
Cleaning up to begin transferring vReg struct and functions to class

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mydevices.h Show annotated file Show diff for this revision Revisions of this file
netStatReg.lib Show annotated file Show diff for this revision Revisions of this file
netStatusReg.cpp Show diff for this revision Revisions of this file
netStatusReg.h Show diff for this revision Revisions of this file
netdevices.h Show annotated file Show diff for this revision Revisions of this file
selMsg.cpp Show annotated file Show diff for this revision Revisions of this file
selMsg.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Oct 07 19:40:36 2019 +0000
+++ b/main.cpp	Fri Oct 11 16:32:45 2019 +0000
@@ -25,12 +25,18 @@
 Timer netDevTimers[7];
 
 struct netsys net1;
-netDevStatus netStat(0,0,0,0,0);
+netDevStatus netStat(0,0,0,0,0,setConsFailCount);
 
 struct vRegData vReg1;
 
 analogAverager voltageAvg(120,true,true,0.9,true,true,1.1);
 analogMinMax voltageMinMax(120,true,true,0.9,true,true,1.1);
+analogAverager currentAvg(50,true,false,-100,true,false,100);
+analogMinMax currentMinMax(50,true,false,-100,true,false,100);
+analogAverager powerAvg(360000,true,false,720000,true,false,720000);
+analogMinMax powerMinMax(360000,true,false,-720000,true,false,720000);
+analogAverager reactiveAvg(0,true,false,-360000,true,false,360000);
+analogMinMax reactiveMinMax(0,true,false,-360000,true,false,360000);
 counterMinMax tapMinMax(0,true,-16,true,16);
 
 bool polltick;
@@ -179,9 +185,9 @@
     
     net1.cltPort=setclientport;
     net1.srv_addr=setclientaddress;
-    net1.srv_sock.set_blocking(true);
+    net1.srv_sock.set_blocking(false);
     net1.srv_sock.set_timeout(100);
-    net1.srv.set_blocking(true);
+    net1.srv.set_blocking(false);
     net1.srv.set_timeout(100);
     net1.sendRetryCount=0;
     net1.messageFailCount=0;
@@ -231,6 +237,7 @@
                 sport0.write(cbuf,clen);
                 netDevTimers[5].reset();
                 clen=0;
+                netStat.iedOnline(true);
             }
         }
         //Check to see if at least 4 characters have been received
@@ -246,6 +253,7 @@
                     netStat.bit_toclear(fmCfgInProg);
                     netStat.bit_toset(devOnline);
                     clen=0;
+                    netStat.iedOnline(true);
                     break;
                 }
                 //Check to see if serial commands are currently being received
@@ -259,6 +267,7 @@
                         netDevTimers[5].reset();
                         netStat.setDevMsgReq(0);
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //If relay acknowledges tap report command set bulk receive flag
@@ -269,6 +278,7 @@
                         netDevTimers[5].reset();
                         netStat.setDevMsgReq(0);
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //If relay acknowledges level 1 login attempt increment command pointer to password
@@ -279,6 +289,7 @@
                         sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
                         netDevTimers[5].reset();
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //If relay sends mask character increment command pointer to send \r\n
@@ -289,6 +300,7 @@
                         sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
                         netDevTimers[5].reset();
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //If relay is in access level 1 or higher increment command pointer to desired command
@@ -299,6 +311,7 @@
                         sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
                         netDevTimers[5].reset();
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //If relay in level 0 increment command pointer to access command
@@ -309,6 +322,7 @@
                         sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
                         netDevTimers[5].reset();
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                 }
@@ -357,6 +371,7 @@
                         //bit_toset(net2->statusReg,fmEnabled);
                         netStat.bit_toset(fmEnabled);
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //Receive data
@@ -392,6 +407,13 @@
                         tapMinMax.putVal(vReg1.analogs[7].analog1Value);
                         voltageMinMax.putVal(vReg1.analogs[9].analog1Value);
                         voltageAvg.putVal(vReg1.analogs[9].analog1Value);
+                        currentMinMax.putVal(vReg1.analogs[0].analog1Value);
+                        currentAvg.putVal(vReg1.analogs[0].analog1Value);
+                        powerMinMax.putVal(vReg1.analogs[11].analog1Value);
+                        powerAvg.putVal(vReg1.analogs[11].analog1Value);
+                        reactiveMinMax.putVal(vReg1.analogs[12].analog1Value);
+                        reactiveAvg.putVal(vReg1.analogs[12].analog1Value);
+                        netStat.iedOnline(true);
                         break;
                     }
                 }
@@ -429,6 +451,7 @@
                         }
                         netStat.bit_toset(fmdEnabled);
                         clen=0;
+                        netStat.iedOnline(true);
                         break;
                     }
                     //Receive demand data
@@ -455,20 +478,7 @@
                         timepack.bytes[0]=cbuf[anum+7];
                         vReg1.demTimeStamp.msec=timepack.cmdshort;
                         sport0.printf("%d/%d/%d %d:%d:%d.%d\r\n",vReg1.demTimeStamp.month,vReg1.demTimeStamp.day,vReg1.demTimeStamp.year,vReg1.demTimeStamp.hour,vReg1.demTimeStamp.min,vReg1.demTimeStamp.sec,vReg1.demTimeStamp.msec);
-                        /*vReg1.calculated[0].analog1Value=voltageMinMax.getMin();
-                        vReg1.calculated[1].analog1Value=voltageAvg.getAvg();
-                        vReg1.calculated[2].analog1Value=voltageMinMax.getMax();
-                        vReg1.calculated[3].analog1Value=tapMinMax.getMin();
-                        vReg1.calculated[4].analog1Value=tapMinMax.getMax();
-                        sport0.printf("%.2f\r\n",vReg1.calculated[0].analog1Value);
-                        sport0.printf("%.2f\r\n",vReg1.calculated[1].analog1Value);
-                        sport0.printf("%.2f\r\n",vReg1.calculated[2].analog1Value);
-                        sport0.printf("%.2f\r\n",vReg1.calculated[3].analog1Value);
-                        sport0.printf("%.2f\r\n",vReg1.calculated[4].analog1Value);
-                        
-                        voltageAvg.resetNum();
-                        voltageMinMax.resetNum();
-                        tapMinMax.resetNum();*/
+                        netStat.iedOnline(true);
                         break;
                     }
                 }
@@ -494,17 +504,11 @@
             //Attempt to connect to server
             while (net2->sendState==3)
             {
-                //delay connect attempt if previous attempt unsuccessful
-                if (netStat.bit_isset(connectRetry))
-                {
-                    wait_ms(100);
-                }
                 //Attempt to connect
                 ret = net2->srv_sock.connect(net2->srv_addr,net2->cltPort);
                 //If connect successful proceed to send data
                 if (ret==0)
                 {
-                    netStat.bit_toclear(connectRetry);
                     #ifdef netmsgdebug
                     printf("Connected %d\r\n",ret);
                     #endif
@@ -516,39 +520,22 @@
                     #ifdef netmsgdebug
                     printf("May already be connected, attempting send.\r\n");
                     #endif
-                    netStat.bit_toclear(connectRetry);
                     net2->sendState=4;
                 }
-                //If connect attempt failed on other error attempt reconnect
                 else
                 {
-                    netStat.bit_toset(connectRetry);
-                    net2->sendRetryCount++;
                     #ifdef netmsgdebug
-                    printf("Connect Attempt Failed, Code: %d\r\n",ret);
+                    printf("Communication Failed, Closing\r\n");
                     #endif
-                    //If connect attempt failed exceeds 3 then end attempt
-                    if (net2->sendRetryCount>3)
-                    {
-                        #ifdef netmsgdebug
-                        printf("Communication Failed, Closing\r\n");
-                        #endif
-                        netStat.bit_toclear(connectRetry);
-                        net2->sendRetryCount = 0;
-                        net2->messageFailCount++;
-                        netStat.bit_toset(cltCloseConnection);
-                        net2->sendState=0;
-                    }
+                    net2->sendRetryCount = 0;
+                    netStat.iedOnline(false);
+                    netStat.bit_toset(cltCloseConnection);
+                    net2->sendState=0;
                 }
             }
             //Attempt to send data
             while (net2->sendState==4)
             {
-                //Delay send data attempt if previous attempt failed
-                if (netStat.bit_isset(sendRetry))
-                {
-                    wait_ms(100);
-                }
                 //Attempt to send data
                 ret = net2->srv_sock.send(net2->sendString,net2->sendLen);
                 //If data send successful proceed to wait for response
@@ -557,31 +544,28 @@
                     #ifdef netmsgdebug
                     printf("Send Result %d\r\n",ret);
                     #endif
-                    netStat.bit_toclear(sendRetry);
-                    //net2->txMessageCount++;
                     netStat.incCount(1);
                     net2->sendState=5;
+                    /*if ((netStat.bit_isset(fmPollReq)) || (netStat.bit_isset(fmdPollReq)))
+                    {
+                        netDevTimers[4].reset();
+                        netDevTimers[4].start();
+                    }
+                    if (netStat.bit_isset(serPollReq))
+                    {
+                        netDevTimers[5].reset();
+                        netDevTimers[5].start();
+                    }*/
                 }
-                //If send attempt failed attempt to re-send data
                 else
                 {
-                    netStat.bit_toset(sendRetry);
-                    net2->sendRetryCount++;
                     #ifdef netmsgdebug
-                    printf("Send Attempt Failed, Code: %d\r\n",ret);
+                    printf("Communication Failed, Closing\r\n");
                     #endif
-                    //If send attempt failed exceeds 3 then end attempt
-                    if (net2->sendRetryCount>3)
-                    {
-                        #ifdef netmsgdebug
-                        printf("Communication Failed, Closing\r\n");
-                        #endif
-                        netStat.bit_toclear(sendRetry);
-                        net2->sendRetryCount = 0;
-                        net2->messageFailCount++;
-                        netStat.bit_toset(cltCloseConnection);
-                        net2->sendState=0;
-                    }
+                    net2->sendRetryCount = 0;
+                    netStat.iedOnline(false);
+                    netStat.bit_toset(cltCloseConnection);
+                    net2->sendState=0;
                 }
             }
         }
@@ -717,7 +701,12 @@
                         #ifdef netmsgdebug
                         printf("STATS\r\n");
                         #endif
-                        sport0.printf("Status %08x\r\n",netStat.getStatus());
+                        sport0.printf("\r\nStatus %08x\r\n",netStat.getStatus());
+                        sport0.printf("Messages Sent: %d\r\n",netStat.getCount(1));
+                        sport0.printf("Messages Received: %d\r\n",netStat.getCount(2));
+                        sport0.printf("Fast Message Timeouts: %d\r\n",netStat.getCount(3));
+                        sport0.printf("Serial Timeouts: %d\r\n",netStat.getCount(4));
+                        sport0.printf("Messages Failed: %d\r\n\r\n",netStat.getCount(5));
                         rxindex=0;
                     }
                 }
@@ -857,73 +846,94 @@
                     vReg1.calculated[0].analog1Value=voltageMinMax.getMin();
                     vReg1.calculated[1].analog1Value=voltageAvg.getAvg();
                     vReg1.calculated[2].analog1Value=voltageMinMax.getMax();
-                    vReg1.calculated[3].analog1Value=tapMinMax.getMin();
-                    vReg1.calculated[4].analog1Value=tapMinMax.getMax();
-                    sport0.printf("%.2f\r\n",vReg1.calculated[0].analog1Value);
-                    sport0.printf("%.2f\r\n",vReg1.calculated[1].analog1Value);
-                    sport0.printf("%.2f\r\n",vReg1.calculated[2].analog1Value);
-                    sport0.printf("%.2f\r\n",vReg1.calculated[3].analog1Value);
-                    sport0.printf("%.2f\r\n",vReg1.calculated[4].analog1Value);
+                    vReg1.calculated[3].analog1Value=currentMinMax.getMin();
+                    vReg1.calculated[4].analog1Value=currentAvg.getAvg();
+                    vReg1.calculated[5].analog1Value=currentMinMax.getMax();
+                    vReg1.calculated[6].analog1Value=powerMinMax.getMin();
+                    vReg1.calculated[7].analog1Value=powerAvg.getAvg();
+                    vReg1.calculated[8].analog1Value=powerMinMax.getMax();
+                    vReg1.calculated[9].analog1Value=reactiveMinMax.getMin();
+                    vReg1.calculated[10].analog1Value=reactiveAvg.getAvg();
+                    vReg1.calculated[11].analog1Value=reactiveMinMax.getMax();
+                    vReg1.calculated[12].analog1Value=tapMinMax.getMin();
+                    vReg1.calculated[13].analog1Value=tapMinMax.getMax();
+                    sport0.printf(
+                    "%2d:%2d  ,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7d,%7d,%7d,%7d,%7d,%7d,%7d,%7d\r\n",
+                    vReg1.timeStamp.hour,vReg1.timeStamp.min,
+                    vReg1.calculated[0].analog1Value,vReg1.calculated[1].analog1Value,vReg1.calculated[2].analog1Value,
+                    vReg1.calculated[3].analog1Value,vReg1.calculated[4].analog1Value,vReg1.calculated[5].analog1Value,
+                    vReg1.calculated[6].analog1Value,vReg1.calculated[7].analog1Value,vReg1.calculated[8].analog1Value,
+                    vReg1.calculated[9].analog1Value,vReg1.calculated[10].analog1Value,vReg1.calculated[11].analog1Value,
+                    vReg1.calculated[12].analog1Value,vReg1.calculated[13].analog1Value);
                     
                     voltageAvg.resetNum();
                     voltageMinMax.resetNum();
+                    currentAvg.resetNum();
+                    currentMinMax.resetNum();
+                    powerAvg.resetNum();
+                    powerMinMax.resetNum();
+                    reactiveAvg.resetNum();
+                    reactiveMinMax.resetNum();
                     tapMinMax.resetNum();
                     
                     netStat.bit_toclear(recDataFile);
                     netDevTimers[6].reset();
                     netDevTimers[6].start();
                 }
-                if (netStat.bit_isset(fmdPollReq))
+                if ((net1.sendState==0) || (net1.sendState==5))
                 {
-                    if (netStat.bit_isset(fmdEnabled))
-                    {
-                        printf("Demand Reading\r\n");
-                        sendCmd(4);
-                        netStat.bit_toclear(fmdPollReq);
-                        netStat.bit_toset(fmdPollInProg);
-                    }
-                    else
+                    if (netStat.bit_isset(fmdPollReq))
                     {
-                        printf("Demand Configuration\r\n");
-                        sendCmd(3);
-                        netStat.bit_toclear(fmdPollReq);
-                        netStat.bit_toset(fmdPollInProg);
+                        if (netStat.bit_isset(fmdEnabled))
+                        {
+                            printf("Demand Reading\r\n");
+                            sendCmd(4);
+                            netStat.bit_toclear(fmdPollReq);
+                            netStat.bit_toset(fmdPollInProg);
+                        }
+                        else
+                        {
+                            printf("Demand Configuration\r\n");
+                            sendCmd(3);
+                            netStat.bit_toclear(fmdPollReq);
+                            netStat.bit_toset(fmdPollInProg);
+                        }
+                        netDevTimers[4].reset();
+                        netDevTimers[4].start();
                     }
-                    netDevTimers[4].reset();
-                    netDevTimers[4].start();
-                }
-                else if (netStat.bit_isset(fmPollReq))
-                {
-                    if (netStat.bit_isset(fmEnabled))
+                    else if (netStat.bit_isset(fmPollReq))
                     {
-                        printf("Meter Reading\r\n");
-                        sendCmd(2);
-                        netStat.bit_toclear(fmPollReq);
-                        netStat.bit_toset(fmPollInProg);
-                    }
-                    else
-                    {
-                        printf("Meter Configuration\r\n");
-                        sendCmd(1);
-                        netStat.bit_toclear(fmPollReq);
-                        netStat.bit_toset(fmPollInProg);
+                        if (netStat.bit_isset(fmEnabled))
+                        {
+                            printf("Meter Reading\r\n");
+                            sendCmd(2);
+                            netStat.bit_toclear(fmPollReq);
+                            netStat.bit_toset(fmPollInProg);
+                        }
+                        else
+                        {
+                            printf("Meter Configuration\r\n");
+                            sendCmd(1);
+                            netStat.bit_toclear(fmPollReq);
+                            netStat.bit_toset(fmPollInProg);
+                        }
+                        netDevTimers[4].reset();
+                        netDevTimers[4].start();
                     }
-                    netDevTimers[4].reset();
-                    netDevTimers[4].start();
-                }
-                else if (netStat.bit_isset(serPollReq))
-                {
-                    if (netStat.bit_isset(serEnabled))
+                    else if (netStat.bit_isset(serPollReq))
                     {
-                        sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
-                        netStat.bit_toclear(serPollReq);
-                        netStat.bit_toset(serPollInProg);
-                        netDevTimers[5].reset();
-                        netDevTimers[5].start();
-                    }
-                    else
-                    {
-                        netStat.bit_toclear(serPollReq);
+                        if (netStat.bit_isset(serEnabled))
+                        {
+                            sendSerCmd(serCmdSeq[netStat.getDevMsgReq()][netStat.getDevMsgPos()],serCmdlen[netStat.getDevMsgReq()][netStat.getDevMsgPos()]);
+                            netStat.bit_toclear(serPollReq);
+                            netStat.bit_toset(serPollInProg);
+                            netDevTimers[5].reset();
+                            netDevTimers[5].start();
+                        }
+                        else
+                        {
+                            netStat.bit_toclear(serPollReq);
+                        }
                     }
                 }
             }
@@ -943,7 +953,6 @@
         if (sendtick)
         {
             setSendTick(false);
-            //sport0.printf("Status %08x\r\n",netStat.getStatus());
             switch (net1.sendState)
             {
                 case 0:
@@ -973,43 +982,18 @@
                         }
                         else
                         {
-                            netStat.bit_toset(attachRetry);
-                            net1.sendRetryCount=0;
-                            net1.sendState=2;
+                            #ifdef netmsgdebug
+                            printf("Communication Failed, Closing\r\n");
+                            #endif
+                            net1.sendRetryCount = 0;
+                            netStat.iedOnline(false);
+                            net1.sendState=0;
                             break;
                         }
                     }
                     net1.sendState=3;
                     netStat.bit_toset(cltIsActive);
                     break;
-                case 2:
-                    ret=net1.srv_sock.open(&eth);
-                    #ifdef netmsgdebug
-                    printf("Socket%d\r\n",ret);
-                    #endif
-                    if (ret < 0)
-                    {
-                        netStat.bit_toset(attachRetry);
-                        net1.sendRetryCount++;
-                        #ifdef netmsgdebug
-                        printf("Attach Attempt Failed, Code: %d\r\n",ret);
-                        #endif
-                        if (net1.sendRetryCount>3)
-                        {
-                            #ifdef netmsgdebug
-                            printf("Communication Failed, Closing\r\n");
-                            #endif
-                            netStat.bit_toclear(attachRetry);
-                            net1.sendRetryCount = 0;
-                            net1.messageFailCount++;
-                            net1.sendState=0;
-                        }
-                        break;
-                    }
-                    net1.sendState=3;
-                    netStat.bit_toclear(attachRetry);
-                    netStat.bit_toset(cltIsActive);
-                    break;
                 case 5:
                     if (!sendLength.empty())
                     {
--- a/mydevices.h	Mon Oct 07 19:40:36 2019 +0000
+++ b/mydevices.h	Fri Oct 11 16:32:45 2019 +0000
@@ -2,7 +2,8 @@
 #define sportEnabled
 #define setPollEnabled
 #define fastMeterEnabled
-#define fastDemandEnabled
+//#define fastDemandEnabled
+#define setConsFailCount 3
 
 #define setDataRecInterval 90000
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/netStatReg.lib	Fri Oct 11 16:32:45 2019 +0000
@@ -0,0 +1,1 @@
+netStatReg#af3075c48866
--- a/netStatusReg.cpp	Mon Oct 07 19:40:36 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-#include "netStatusReg.h"
-
-//static volatile unsigned int statusReg = 0;
-
-netDevStatus::netDevStatus(unsigned int setStatus,unsigned int settxMC,unsigned int setrxMC,unsigned int setfmTC,unsigned int setsTC)
-{
-    statusReg = setStatus;
-    txMessageCount=settxMC;
-    rxMessageCount=setrxMC;
-    fmTimeoutCount=setfmTC;
-    serTimeoutCount=setsTC;
-}
-
-unsigned int netDevStatus::getStatus(void)
-{
-    return statusReg;
-}
-
-//Get count Value
-unsigned int netDevStatus::getCount(char counterNum)
-{
-    switch (counterNum)
-    {
-        case 1:
-            return txMessageCount;
-        case 2:
-            return rxMessageCount;
-        case 3:
-            return fmTimeoutCount;
-        case 4:
-            return serTimeoutCount;
-        default:
-            return 0;
-    }
-}
-
-//Increment count Value
-void netDevStatus::incCount(char counterNum)
-{
-    switch (counterNum)
-    {
-        case 1:
-            txMessageCount++;
-            break;
-        case 2:
-            rxMessageCount++;
-            break;
-        case 3:
-            fmTimeoutCount++;
-            break;
-        case 4:
-            serTimeoutCount++;
-            break;
-        default:
-            break;
-    }
-}
-
-//Set count Value
-void netDevStatus::setCount(char counterNum, unsigned int newCount)
-{
-    switch (counterNum)
-    {
-        case 1:
-            txMessageCount=newCount;
-            break;
-        case 2:
-            rxMessageCount=newCount;
-            break;
-        case 3:
-            fmTimeoutCount=newCount;
-            break;
-        case 4:
-            serTimeoutCount=newCount;
-            break;
-        default:
-            break;
-    }
-}
-
-void netDevStatus::setDevMsgReq(char setReq)
-{
-    devMsgReq=setReq;
-}
-char netDevStatus::getDevMsgReq(void)
-{
-    return devMsgReq;
-}
-void netDevStatus::setDevMsgPos(char setPos)
-{
-    devMsgPos=setPos;
-}
-char netDevStatus::getDevMsgPos(void)
-{
-    return devMsgPos;
-}
-//Return true if bit is set
-bool netDevStatus::bit_isset(unsigned int m)
-{
-    return (((statusReg) & (m)) ? true : false);
-}
-
-//Return true if bit is clear
-bool netDevStatus::bit_isclear(unsigned int m)
-{
-    return  (((statusReg) & (m)) ? false : true);
-}
-
-//Set bit
-void netDevStatus::bit_toset(unsigned int m)
-{
-    ((statusReg) |= (m));
-}
-
-//Clear bit
-void netDevStatus::bit_toclear(unsigned int m)
-{
-    ((statusReg) &= ~(m));
-}
-//Bit set if set, do nothing if not set
-void netDevStatus::bit_sis(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) |= (m)) : (statusReg = statusReg));
-}
-//Bit clear if set, do nothing if not set
-void netDevStatus::bit_cis(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) &= ~(m)) : (statusReg = statusReg));
-}
-//Bit set if set, clear if not set
-void netDevStatus::bit_sisc(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) |= (m)) : ((statusReg) &= ~(m)));
-}
-//Bit clear if set, set if not set
-void netDevStatus::bit_ciss(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) &= ~(m)) : ((statusReg) |= (m)));
-}
-
-//Bit set if clear, do nothing if set
-void netDevStatus::bit_sic(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? (statusReg = statusReg) : ((statusReg) |= (m)));
-}
-//Bit clear if clear, do nothing if set
-void netDevStatus::bit_cic(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? (statusReg = statusReg) : ((statusReg) &= ~(m)));
-}
-//Bit set if clear, clear if set
-void netDevStatus::bit_sicc(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) &= ~(m)) : ((statusReg) |= (m)));
-}
-//Bit clear if clear, set if set
-void netDevStatus::bit_cics(unsigned int c,unsigned int m)
-{
-    (((statusReg) & (c)) ? ((statusReg) |= (m)) : ((statusReg) &= ~(m)));
-}
\ No newline at end of file
--- a/netStatusReg.h	Mon Oct 07 19:40:36 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#ifndef MKNETATATREG_H
-#define MKNETATATREG_H
-
-class netDevStatus
-{
-        unsigned int statusReg;
-    
-        unsigned int txMessageCount;  //1
-        unsigned int rxMessageCount;  //2
-        unsigned int fmTimeoutCount;  //3
-        unsigned int serTimeoutCount; //4
-        
-        char devMsgReq;
-        char devMsgPos;
-    
-    public:
-        
-        netDevStatus(unsigned int,unsigned int,unsigned int,unsigned int,unsigned int);
-    
-        unsigned int getStatus(void);
-        
-        //Get count Value
-        unsigned int getCount(char);
-        
-        //Increment count Value
-        void incCount(char);
-        
-        //Set count Value
-        void setCount(char, unsigned int);
-        
-        void setDevMsgReq(char);
-        
-        char getDevMsgReq(void);
-                
-        void setDevMsgPos(char);
-        
-        char getDevMsgPos(void);
-                
-        //Return true if bit is set
-        bool bit_isset(unsigned int);
-        //Return true if bit is clear
-        bool bit_isclear(unsigned int);
-        //Set bit
-        void bit_toset(unsigned int);
-        //Clear bit
-        void bit_toclear(unsigned int);
-        
-        //Bit set if set, do nothing if not set
-        void bit_sis(unsigned int,unsigned int);
-        //Bit clear if set, do nothing if not set
-        void bit_cis(unsigned int,unsigned int);
-        //Bit set if set, clear if not set
-        void bit_sisc(unsigned int,unsigned int);
-        //Bit clear if set, set if not set
-        void bit_ciss(unsigned int,unsigned int);
-        
-        //Bit set if clear, do nothing if set
-        void bit_sic(unsigned int,unsigned int);
-        //Bit clear if clear, do nothing if set
-        void bit_cic(unsigned int,unsigned int);
-        //Bit set if clear, clear if set
-        void bit_sicc(unsigned int,unsigned int);
-        //Bit clear if clear, set if set
-        void bit_cics(unsigned int,unsigned int);
-};
-#endif
\ No newline at end of file
--- a/netdevices.h	Mon Oct 07 19:40:36 2019 +0000
+++ b/netdevices.h	Fri Oct 11 16:32:45 2019 +0000
@@ -4,44 +4,6 @@
 #include "TCPServer.h"
 #include "TCPSocket.h"
 
-
-#define pollEnabled         0x80000000
-#define fmEnabled           0x40000000
-#define fmdEnabled          0x20000000
-#define serEnabled          0x10000000
-#define srvIsActive         0x08000000
-#define srvCloseConnection  0x04000000
-#define cltIsActive         0x02000000
-#define cltCloseConnection  0x01000000
-#define serIsActive         0x00800000
-#define connectRetry        0x00400000
-#define attachRetry         0x00200000
-#define sendRetry           0x00100000
-#define serTimeout          0x00080000
-#define fmTimeout           0x00040000
-#define fmdTimeout          0x00020000
-#define serMsgRx            0x00010000
-#define serPollReq          0x00008000
-#define fmPollReq           0x00004000
-#define fmdPollReq          0x00002000
-#define fmCfgReq            0x00001000
-#define serPollInProg       0x00000800
-#define fmPollInProg        0x00000400
-#define fmdPollInProg       0x00000200
-#define fmCfgInProg         0x00000100
-#define serRespRx           0x00000080
-#define fmRespRx            0x00000040
-#define fmdRespRx           0x00000020
-#define recDataFile         0x00000010
-#define serCloseConnection  0x00000008
-#define fmCloseConnection   0x00000004
-#define fmdCloseConnection  0x00000002
-#define devOnline           0x00000001
-
-#define cltclose            0x03FF0EEE
-#define serclose            0x03700888
-#define fmclose             0x03700766
-
 void confignetdevices(EthernetInterface *eth);
 
 struct netsys 
--- a/selMsg.cpp	Mon Oct 07 19:40:36 2019 +0000
+++ b/selMsg.cpp	Fri Oct 11 16:32:45 2019 +0000
@@ -35,6 +35,15 @@
     strcpy(vReg->calculated[0].analogName,"VLSMIN");
     strcpy(vReg->calculated[1].analogName,"VLSAVG");
     strcpy(vReg->calculated[2].analogName,"VLSMAX");
-    strcpy(vReg->calculated[3].analogName,"TAPMIN");
-    strcpy(vReg->calculated[4].analogName,"TAPMAX");
+    strcpy(vReg->calculated[3].analogName,"ILMIN\0");
+    strcpy(vReg->calculated[4].analogName,"ILAVG\0");
+    strcpy(vReg->calculated[5].analogName,"ILMA\0");
+    strcpy(vReg->calculated[6].analogName,"PLMIN\0");
+    strcpy(vReg->calculated[7].analogName,"PLAVG\0");
+    strcpy(vReg->calculated[8].analogName,"PLMAX\0");
+    strcpy(vReg->calculated[9].analogName,"QLMIN\0");
+    strcpy(vReg->calculated[10].analogName,"QLAVG\0");
+    strcpy(vReg->calculated[11].analogName,"QLMAX\0");
+    strcpy(vReg->calculated[12].analogName,"TAPMIN");
+    strcpy(vReg->calculated[13].analogName,"TAPMAX");
 }
--- a/selMsg.h	Mon Oct 07 19:40:36 2019 +0000
+++ b/selMsg.h	Fri Oct 11 16:32:45 2019 +0000
@@ -69,10 +69,21 @@
     char numDigital;
     char numDemAnalog;
     struct analog1Sample analogs[27];
-    struct analog1Sample calculated[5];
+    struct analog1Sample calculated[14];
     struct fmTimeStamp timeStamp;
     struct fmTimeStamp  demTimeStamp;
     char digitalTargets[52];
+    char tapOff;
+    char noNeut;
+    char tapDiff;
+    char remCount;
+    char locCount;
+    char autoCount;
+    char manCount;
+    char vripCount;
+    char neutCount;
+    char maxCount;
+    char minCount;    
 };
 
 void initVoltageRegulator(vRegData *vReg);