|
@@ -42,9 +42,6 @@
|
|
|
#include "Common.h"
|
|
|
|
|
|
typedef unsigned char byte;
|
|
|
-#define PASS 1
|
|
|
-#define FAIL -1
|
|
|
-#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
|
|
|
#define NO_DEFINE 255
|
|
|
#define DEFAULT_AC_INDEX 2
|
|
|
|
|
@@ -65,7 +62,6 @@ struct PsuData *ShmPsuData;
|
|
|
ChargerInfoData *ShmChargerInfo;
|
|
|
PsuPositionInfoData *ShmPsuPosition;
|
|
|
PsuGroupingInfoData *ShmPsuGrouping;
|
|
|
-PsuGroupCollectionData *ShmGroupCollection;
|
|
|
|
|
|
struct ChargingInfoData *_chargingData[CONNECTOR_QUANTITY];
|
|
|
struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
@@ -247,7 +243,6 @@ int InitShareMemory()
|
|
|
{
|
|
|
ShmPsuPosition = &ShmChargerInfo->PsuPosition;
|
|
|
ShmPsuGrouping = &ShmChargerInfo->PsuGrouping;
|
|
|
- ShmGroupCollection = &ShmChargerInfo->PsuGrouping.GroupCollection[0];
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -1487,11 +1482,11 @@ void SetGroupRole(byte group, byte role)
|
|
|
{
|
|
|
if(group < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
- if(ShmGroupCollection[group].Role != role)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != role)
|
|
|
{
|
|
|
//printf("\r\nSet Group %d Role = %d", group, role);
|
|
|
}
|
|
|
- ShmGroupCollection[group].Role = role;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].Role = role;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1500,9 +1495,9 @@ void SetGroupToIdle(byte group)
|
|
|
if(group < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
SetGroupRole(group, _GROLE_IDLE);
|
|
|
- ShmGroupCollection[group].Partner.Quantity = 0;
|
|
|
- memset(ShmGroupCollection[group].Partner.Member, 0x00, ARRAY_SIZE(ShmGroupCollection[group].Partner.Member));
|
|
|
- ShmGroupCollection[group].TargetGroup = 0;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity = 0;
|
|
|
+ memset(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member, 0x00, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member));
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = 0;
|
|
|
//printf("\r\n Reset Group %02X To Idle", group);
|
|
|
}
|
|
|
}
|
|
@@ -1512,7 +1507,7 @@ void SetGroupToMaster(byte group)
|
|
|
if(group < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
SetGroupRole(group, _GROLE_MASTER);
|
|
|
- ShmGroupCollection[group].TargetGroup = group + 1;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = group + 1;
|
|
|
//printf("\r\n Set Group %02X As Master", group);
|
|
|
}
|
|
|
}
|
|
@@ -1522,7 +1517,7 @@ void SetGroupToSlave(byte group, byte target)
|
|
|
if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
SetGroupRole(group, _GROLE_SLAVE);
|
|
|
- ShmGroupCollection[group].TargetGroup = target + 1;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = target + 1;
|
|
|
//printf("\r\n Set Group %02X As Slave", group);
|
|
|
}
|
|
|
}
|
|
@@ -1535,25 +1530,25 @@ void AddGroupCollection(byte group, byte target)
|
|
|
|
|
|
if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
- if(ShmGroupCollection[target].Role != _GROLE_MASTER)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[target].Role != _GROLE_MASTER)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if(ShmGroupCollection[group].Role != _GROLE_IDLE &&
|
|
|
- ShmGroupCollection[group].Role != _GROLE_WAIT_IDLE &&
|
|
|
- ShmGroupCollection[group].Role != _GROLE_PRECHARGE_READY)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_IDLE &&
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_WAIT_IDLE &&
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_PRECHARGE_READY)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SetGroupToSlave(group, target);
|
|
|
- ShmGroupCollection[target].Partner.Member[ShmGroupCollection[target].Partner.Quantity++] = group;
|
|
|
- ParallelConfig = ShmGroupCollection[target].ParallelConfig[group];
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity++] = group;
|
|
|
+ ParallelConfig = ShmChargerInfo->PsuGrouping.GroupCollection[target].ParallelConfig[group];
|
|
|
if(ParallelConfig != 0)
|
|
|
{
|
|
|
ShmPsuGrouping->ParallelRelayConfig.CtrlValue |= (1 << (ParallelConfig - 1));
|
|
|
}
|
|
|
- //printf("\r\n Add Group %02X To Gun %d (Quantity %d), Set Parallel Relay %d On", group, target + 1, ShmGroupCollection[target].Partner.Quantity, ParallelConfig);
|
|
|
+ //printf("\r\n Add Group %02X To Gun %d (Quantity %d), Set Parallel Relay %d On", group, target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ParallelConfig);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1567,11 +1562,11 @@ void RemoveGroupCollection(byte group, byte target)
|
|
|
|
|
|
if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
- for(int i = 0; i < ShmGroupCollection[target].Partner.Quantity; i++)
|
|
|
+ for(int i = 0; i < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity; i++)
|
|
|
{
|
|
|
- if(group == ShmGroupCollection[target].Partner.Member[i])
|
|
|
+ if(group == ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i])
|
|
|
{
|
|
|
- ShmGroupCollection[target].Partner.Member[i] = 0;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i] = 0;
|
|
|
location = i;
|
|
|
find = true;
|
|
|
break;
|
|
@@ -1579,20 +1574,20 @@ void RemoveGroupCollection(byte group, byte target)
|
|
|
}
|
|
|
if(find)
|
|
|
{
|
|
|
- for(int i = location + 1; i < ShmGroupCollection[target].Partner.Quantity; i++)
|
|
|
+ for(int i = location + 1; i < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity; i++)
|
|
|
{
|
|
|
- slave = ShmGroupCollection[target].Partner.Member[i];
|
|
|
- ShmGroupCollection[target].Partner.Member[i] = 0;
|
|
|
- ShmGroupCollection[target].Partner.Member[i - 1] = slave;
|
|
|
+ slave = ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i];
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i] = 0;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i - 1] = slave;
|
|
|
}
|
|
|
- ShmGroupCollection[target].Partner.Quantity--;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity--;
|
|
|
SetGroupToIdle(group);
|
|
|
- ParallelConfig = ShmGroupCollection[target].ParallelConfig[group];
|
|
|
+ ParallelConfig = ShmChargerInfo->PsuGrouping.GroupCollection[target].ParallelConfig[group];
|
|
|
if(ParallelConfig != 0)
|
|
|
{
|
|
|
ShmPsuGrouping->ParallelRelayConfig.CtrlValue &= ~(1 << (ParallelConfig - 1));
|
|
|
}
|
|
|
- //printf("\r\n Remove Group %02X From Gun %d (Quantity %d), Clean Parallel Relay %d Off", group, target + 1, ShmGroupCollection[target].Partner.Quantity, ParallelConfig);
|
|
|
+ //printf("\r\n Remove Group %02X From Gun %d (Quantity %d), Clean Parallel Relay %d Off", group, target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ParallelConfig);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1609,14 +1604,14 @@ void ShowGroupingInfo(void)
|
|
|
{
|
|
|
target = ShmPsuGrouping->Layout[i];
|
|
|
printf("\r\n %d (%2d) %2d %d %02X ",
|
|
|
- target + 1, _chargingData[target]->SystemStatus, ShmGroupCollection[target].Role,
|
|
|
- ShmGroupCollection[target].Partner.Quantity, ShmGroupCollection[target].TargetGroup);
|
|
|
+ target + 1, _chargingData[target]->SystemStatus, ShmChargerInfo->PsuGrouping.GroupCollection[target].Role,
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup);
|
|
|
|
|
|
for(int j = 0; j < 3; j++)
|
|
|
{
|
|
|
- if(ShmGroupCollection[target].Role == 1 && j < ShmGroupCollection[target].Partner.Quantity)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[target].Role == 1 && j < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity)
|
|
|
{
|
|
|
- printf("[%02X] ", ShmGroupCollection[target].Partner.Member[j]);
|
|
|
+ printf("[%02X] ", ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[j]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1640,19 +1635,19 @@ void PsuGroupSwitchToIdle(byte group)
|
|
|
{
|
|
|
int master = 0, quantity = 0, location = 0, total = 0;
|
|
|
|
|
|
- if(ShmGroupCollection[group].Role != _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_SLAVE)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- master = ShmGroupCollection[group].TargetGroup - 1;
|
|
|
- quantity = ShmGroupCollection[master].Partner.Quantity;
|
|
|
+ master = ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup - 1;
|
|
|
+ quantity = ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Quantity;
|
|
|
//printf("\r\n Search Group %02X From Gun %d", group, master + 1);
|
|
|
for(int i = 0; i < quantity; i++)
|
|
|
{
|
|
|
if(total == 0)
|
|
|
{
|
|
|
- if(group == ShmGroupCollection[master].Partner.Member[i])
|
|
|
+ if(group == ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i])
|
|
|
{
|
|
|
location = i;
|
|
|
total++;
|
|
@@ -1662,20 +1657,20 @@ void PsuGroupSwitchToIdle(byte group)
|
|
|
else
|
|
|
{
|
|
|
// find other group in the same direction
|
|
|
- if(ShmPsuGrouping->Location[ShmGroupCollection[master].Partner.Member[location]] < ShmPsuGrouping->Location[master])
|
|
|
+ if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[location]] < ShmPsuGrouping->Location[master])
|
|
|
{
|
|
|
- if(ShmPsuGrouping->Location[ShmGroupCollection[master].Partner.Member[i]] < ShmPsuGrouping->Location[master])
|
|
|
+ if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]] < ShmPsuGrouping->Location[master])
|
|
|
{
|
|
|
total++;
|
|
|
- //printf("\r\n Find Other Group %02X In The Same Direction", ShmGroupCollection[master].Partner.Member[i]);
|
|
|
+ //printf("\r\n Find Other Group %02X In The Same Direction", ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]);
|
|
|
}
|
|
|
}
|
|
|
- if(ShmPsuGrouping->Location[ShmGroupCollection[master].Partner.Member[location]] > ShmPsuGrouping->Location[master])
|
|
|
+ if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[location]] > ShmPsuGrouping->Location[master])
|
|
|
{
|
|
|
- if(ShmPsuGrouping->Location[ShmGroupCollection[master].Partner.Member[i]] > ShmPsuGrouping->Location[master])
|
|
|
+ if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]] > ShmPsuGrouping->Location[master])
|
|
|
{
|
|
|
total++;
|
|
|
- //printf("\r\n Find Other Group %02X In The Same Direction", ShmGroupCollection[master].Partner.Member[i]);
|
|
|
+ //printf("\r\n Find Other Group %02X In The Same Direction", ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1685,7 +1680,7 @@ void PsuGroupSwitchToIdle(byte group)
|
|
|
{
|
|
|
unsigned char collection[GENERAL_GUN_QUANTITY];
|
|
|
//printf("\r\n There are %d Group Need To Switch Idle:", total);
|
|
|
- memcpy(collection, ShmGroupCollection[master].Partner.Member, ARRAY_SIZE(ShmGroupCollection[master].Partner.Member));
|
|
|
+ memcpy(collection, ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member));
|
|
|
|
|
|
for(int i = 0; i < total; i++)
|
|
|
{
|
|
@@ -1706,7 +1701,7 @@ void FindPsuGroupPartner(byte master, byte quantity, PsuGroupPartner *tPartner)
|
|
|
memset(&partner, 0x00, sizeof(PsuGroupPartner));
|
|
|
|
|
|
// search from left
|
|
|
- location = ShmGroupCollection[master].Location - 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[master].Location - 1;
|
|
|
for(int i = location; i >= 0; i--)
|
|
|
{
|
|
|
if(partner.Quantity >= quantity)
|
|
@@ -1715,14 +1710,14 @@ void FindPsuGroupPartner(byte master, byte quantity, PsuGroupPartner *tPartner)
|
|
|
}
|
|
|
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
//printf("\r\n Find Group %02X From Left", slave);
|
|
|
partner.Member[partner.Quantity++] = slave;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1731,7 +1726,7 @@ void FindPsuGroupPartner(byte master, byte quantity, PsuGroupPartner *tPartner)
|
|
|
}
|
|
|
|
|
|
// search from right
|
|
|
- location = ShmGroupCollection[master].Location + 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[master].Location + 1;
|
|
|
for(int i = location; i < 4; i++)
|
|
|
{
|
|
|
if(partner.Quantity >= quantity)
|
|
@@ -1740,14 +1735,14 @@ void FindPsuGroupPartner(byte master, byte quantity, PsuGroupPartner *tPartner)
|
|
|
}
|
|
|
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
//printf("\r\n Find Group %02X From Right", slave);
|
|
|
partner.Member[partner.Quantity++] = slave;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1769,17 +1764,17 @@ int GetPsuGroupAvailable(byte group)
|
|
|
return partner.Quantity;
|
|
|
#if 0
|
|
|
// search from left
|
|
|
- location = ShmGroupCollection[group].Location - 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
|
|
|
for(int i = location; i >= 0; i--)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
available++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1787,17 +1782,17 @@ int GetPsuGroupAvailable(byte group)
|
|
|
}
|
|
|
}
|
|
|
// search from right
|
|
|
- location = ShmGroupCollection[group].Location + 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
|
|
|
for(int i = location; i < 4; i++)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
available++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1816,18 +1811,18 @@ void PsuGroupShareCheck(byte group)
|
|
|
//printf("\r\n Gun %d Total Group = %d", group + 1, total);
|
|
|
|
|
|
// search from left
|
|
|
- location = ShmGroupCollection[group].Location - 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
|
|
|
for(int i = location; i >= 0; i--)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
- target = ShmGroupCollection[slave].TargetGroup - 1;
|
|
|
- if((ShmGroupCollection[target].Partner.Quantity + 1) > total)
|
|
|
+ target = ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1;
|
|
|
+ if((ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1) > total)
|
|
|
{
|
|
|
- share = (ShmGroupCollection[target].Partner.Quantity + 1 - total) / 2;
|
|
|
+ share = (ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1 - total) / 2;
|
|
|
}
|
|
|
- //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmGroupCollection[target].Partner.Quantity, share);
|
|
|
+ //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, share);
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
@@ -1839,18 +1834,18 @@ void PsuGroupShareCheck(byte group)
|
|
|
if(share == 0)
|
|
|
{
|
|
|
// search from right
|
|
|
- location = ShmGroupCollection[group].Location + 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
|
|
|
for(int i = location; i < 4; i++)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
- target = ShmGroupCollection[slave].TargetGroup - 1;
|
|
|
- if((ShmGroupCollection[target].Partner.Quantity + 1) > total)
|
|
|
+ target = ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1;
|
|
|
+ if((ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1) > total)
|
|
|
{
|
|
|
- share = (ShmGroupCollection[target].Partner.Quantity + 1 - total) / 2;
|
|
|
+ share = (ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1 - total) / 2;
|
|
|
}
|
|
|
- //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmGroupCollection[target].Partner.Quantity, share);
|
|
|
+ //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, share);
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
@@ -1877,17 +1872,17 @@ void SimplePsuGroupStartCharging(byte group)
|
|
|
int available = 0;
|
|
|
PsuGroupPartner partner;
|
|
|
|
|
|
- if(ShmGroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(ShmGroupCollection[group].Role != _GROLE_IDLE && ShmGroupCollection[group].Role != _GROLE_MASTER)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_IDLE && ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_MASTER)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(ShmGroupCollection[group].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
SetGroupToMaster(group);
|
|
|
|
|
@@ -1916,18 +1911,18 @@ void SimplePsuGroupStartCharging(byte group)
|
|
|
|
|
|
#if 0
|
|
|
// search from left
|
|
|
- location = ShmGroupCollection[group].Location - 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
|
|
|
for(int i = location; i >= 0; i--)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
//printf("\r\n Find %02X From Left", slave);
|
|
|
AddGroupCollection(slave, group);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1936,18 +1931,18 @@ void SimplePsuGroupStartCharging(byte group)
|
|
|
}
|
|
|
|
|
|
// search from right
|
|
|
- location = ShmGroupCollection[group].Location + 1;
|
|
|
+ location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
|
|
|
for(int i = location; i < 4; i++)
|
|
|
{
|
|
|
slave = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
|
|
|
{
|
|
|
//printf("\r\n Find %02X From Right", slave);
|
|
|
AddGroupCollection(slave, group);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmGroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmGroupCollection[slave].TargetGroup - 1))
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -1961,17 +1956,17 @@ void PsuGroupStopCharging(byte group)
|
|
|
{
|
|
|
int total = 0;
|
|
|
|
|
|
- if(ShmGroupCollection[group].Role != _GROLE_MASTER)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_MASTER)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- total = ShmGroupCollection[group].Partner.Quantity;
|
|
|
+ total = ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity;
|
|
|
if(total > 0)
|
|
|
{
|
|
|
unsigned char collection[GENERAL_GUN_QUANTITY];
|
|
|
- //printf("\r\n There are %d Group Need To Stop:", ShmGroupCollection[group].Partner.Quantity);
|
|
|
- memcpy(collection, ShmGroupCollection[group].Partner.Member, ARRAY_SIZE(ShmGroupCollection[group].Partner.Member));
|
|
|
+ //printf("\r\n There are %d Group Need To Stop:", ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity);
|
|
|
+ memcpy(collection, ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member));
|
|
|
|
|
|
for(int i = 0; i < total; i++)
|
|
|
{
|
|
@@ -2001,7 +1996,7 @@ void RunSimplePsuGrouping(char *v1, char *v2)
|
|
|
{
|
|
|
if(charging > 0)
|
|
|
{
|
|
|
- if(ShmGroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
//printf("\r\nGroup %02X Is In Use, Need To Stop Charging", group);
|
|
|
PsuGroupSwitchToIdle(group);
|
|
@@ -2011,11 +2006,11 @@ void RunSimplePsuGrouping(char *v1, char *v2)
|
|
|
}
|
|
|
if(charging == 0)
|
|
|
{
|
|
|
- if(ShmGroupCollection[group].Role == _GROLE_MASTER)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_MASTER)
|
|
|
{
|
|
|
PsuGroupStopCharging(group);
|
|
|
}
|
|
|
- if(ShmGroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
PsuGroupSwitchToIdle(group);
|
|
|
}
|
|
@@ -2037,7 +2032,17 @@ void ShowCabinetInfo(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity,
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.PresentConnectorQuantity,
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity);
|
|
|
+ printf("\r\n");
|
|
|
+ for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
|
|
|
+ {
|
|
|
+ ipAddress = ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress;
|
|
|
|
|
|
+ printf("\r\n Dispenser Connection[%d] Status: %d, DispenserIndex: %d, IP: %d.%d.%d.%d", i,
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].Status,
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].DispenserIndex,
|
|
|
+ ((ipAddress >> 0) & 0xFF), ((ipAddress >> 8) & 0xFF), ((ipAddress >> 16) & 0xFF), ((ipAddress >> 24) & 0xFF));
|
|
|
+ }
|
|
|
+ printf("\r\n");
|
|
|
for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
|
|
|
{
|
|
|
printf("\r\n Connector[%d] Index: %2X, Status = %2d , %s", i, _chargingData[i]->Index, _chargingData[i]->SystemStatus,
|
|
@@ -2136,9 +2141,9 @@ void ShowGroupingDemand(void)
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
{
|
|
|
target = ShmPsuGrouping->Layout[i];
|
|
|
- if(ShmGroupCollection[target].TargetGroup != 0)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup != 0)
|
|
|
{
|
|
|
- k1k2 = _chargingData[ShmGroupCollection[target].TargetGroup - 1]->RelayK1K2Status;
|
|
|
+ k1k2 = _chargingData[ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup - 1]->RelayK1K2Status;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2146,16 +2151,16 @@ void ShowGroupingDemand(void)
|
|
|
}
|
|
|
|
|
|
printf("\r\n %d %2d %02X %d %4d V %3d.%d A %4d A %3d.%02d",
|
|
|
- target + 1, ShmGroupCollection[target].Role, ShmGroupCollection[target].TargetGroup, k1k2,
|
|
|
+ target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Role, ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup, k1k2,
|
|
|
(ShmPsuGrouping->GroupOutput[target].GTargetVoltage / 10),
|
|
|
(ShmPsuGrouping->GroupOutput[target].GTargetCurrent / 10),
|
|
|
(ShmPsuGrouping->GroupOutput[target].GTargetCurrent % 10),
|
|
|
(int)(_chargingData[target]->AvailableChargingCurrent / 10),
|
|
|
(ShmPsuGrouping->GroupOutput[target].OutputLoading / 100),
|
|
|
(ShmPsuGrouping->GroupOutput[target].OutputLoading % 100));
|
|
|
- if(ShmGroupCollection[target].TargetGroup == target + 1)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup == target + 1)
|
|
|
{
|
|
|
- printf(" %3d.%02d", (ShmGroupCollection[target].GunLoading / 100), (ShmGroupCollection[target].GunLoading % 100));
|
|
|
+ printf(" %3d.%02d", (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading / 100), (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading % 100));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2190,7 +2195,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FTargetVoltage = _voltage * 10;
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FTargetCurrent = _current * 10;
|
|
|
}
|
|
|
- else if(ShmGroupCollection[gun - 1].Role == _GROLE_MASTER)
|
|
|
+ else if(ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_MASTER)
|
|
|
{
|
|
|
if(ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.EnableForceCharging)
|
|
|
{
|
|
@@ -2418,10 +2423,10 @@ void SetGunStopCharging(char *v1)
|
|
|
printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
}
|
|
|
- else if(ShmGroupCollection[gun - 1].Role == _GROLE_SLAVE)
|
|
|
+ else if(ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
printf("\r\nSet Group [%02X] Stop", gun - 1);
|
|
|
- ShmGroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2447,10 +2452,10 @@ void SetGunStopCharging(char *v1)
|
|
|
|
|
|
if(PreviousSystemStatus == 0xFF)
|
|
|
{
|
|
|
- if(ShmGroupCollection[gun - 1].Role == _GROLE_SLAVE)
|
|
|
+ if(ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
printf("\r\nSet Group [%02X] Stop", gun - 1);
|
|
|
- ShmGroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
|
|
|
}
|
|
|
}
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
@@ -2633,10 +2638,10 @@ void SetGunExtend(char *v1)
|
|
|
|
|
|
gun = atoi(v1);
|
|
|
|
|
|
- if(_chargingData[gun - 1]->SystemStatus == S_CHARGING && ShmGroupCollection[gun - 1].Role == _GROLE_MASTER)
|
|
|
+ if(_chargingData[gun - 1]->SystemStatus == S_CHARGING && ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_MASTER)
|
|
|
{
|
|
|
printf("\r\nSet Group [%02X] Extend Capability", gun - 1);
|
|
|
- ShmGroupCollection[gun - 1].GroupCtrl.bits.MorePowerRequest = true;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.MorePowerRequest = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2849,7 +2854,7 @@ void ShowChargerLimit(void)
|
|
|
{
|
|
|
printf(" %7s %2d",
|
|
|
_chargingData[i]->Type <= _Type_GB ? str_gun_type[_chargingData[i]->Type] : "???",
|
|
|
- ShmGroupCollection[i].GunPsuQuantity);
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[i].GunPsuQuantity);
|
|
|
printf(" %4d V %4d A",
|
|
|
(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].RemoteMaxPhysicalVoltage / 10),
|
|
|
(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].RemoteMaxPhysicalCurrent / 10));
|
|
@@ -2859,7 +2864,7 @@ void ShowChargerLimit(void)
|
|
|
limitPower = (int)ShmSysConfigAndInfo->SysInfo.MaxChargingProfilePower;
|
|
|
if(inUsingCnt > 0)
|
|
|
{
|
|
|
- limitPower = (limitPower * ShmGroupCollection[i].GunPsuQuantity) / inUsingCnt;
|
|
|
+ limitPower = (limitPower * ShmChargerInfo->PsuGrouping.GroupCollection[i].GunPsuQuantity) / inUsingCnt;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2902,18 +2907,18 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- memset(&ShmGroupCollection[0], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
- memset(&ShmGroupCollection[1], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
- memset(&ShmGroupCollection[2], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
- memset(&ShmGroupCollection[3], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
- ShmGroupCollection[0].Index = 0;
|
|
|
- ShmGroupCollection[1].Index = 1;
|
|
|
- ShmGroupCollection[2].Index = 2;
|
|
|
- ShmGroupCollection[3].Index = 3;
|
|
|
- ShmGroupCollection[0].Location = 0;
|
|
|
- ShmGroupCollection[1].Location = 3;
|
|
|
- ShmGroupCollection[2].Location = 1;
|
|
|
- ShmGroupCollection[3].Location = 2;
|
|
|
+ memset(&ShmChargerInfo->PsuGrouping.GroupCollection[0], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
+ memset(&ShmChargerInfo->PsuGrouping.GroupCollection[1], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
+ memset(&ShmChargerInfo->PsuGrouping.GroupCollection[2], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
+ memset(&ShmChargerInfo->PsuGrouping.GroupCollection[3], 0x00, sizeof(PsuGroupCollectionData));
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[0].Index = 0;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[1].Index = 1;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[2].Index = 2;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[3].Index = 3;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[0].Location = 0;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[1].Location = 3;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[2].Location = 1;
|
|
|
+ ShmChargerInfo->PsuGrouping.GroupCollection[3].Location = 2;
|
|
|
*/
|
|
|
|
|
|
for(;;)
|