|
@@ -91,7 +91,7 @@ struct OCPP16Data *ShmOCPP16Data;
|
|
|
#define MESSAGE_TYPE_CALLERROR 4
|
|
|
|
|
|
//
|
|
|
-#define server_cycle_Status 120
|
|
|
+//#define server_cycle_Status 120
|
|
|
#define MACROSTR(k) #k
|
|
|
|
|
|
//ConfigurationMaxKeys
|
|
@@ -102,6 +102,11 @@ struct OCPP16Data *ShmOCPP16Data;
|
|
|
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
char queuedata[2600]={0};
|
|
|
|
|
|
+//=================================
|
|
|
+// StatusNotification cycle
|
|
|
+//=================================
|
|
|
+static int server_cycle_Status = 120;
|
|
|
+
|
|
|
//===============================
|
|
|
// Configuration: unknownkey
|
|
|
//===============================
|
|
@@ -692,7 +697,6 @@ static char * ValueFormatStr[] = {
|
|
|
MACROSTR(SignedData)
|
|
|
};
|
|
|
|
|
|
-
|
|
|
/*Measurand*/
|
|
|
typedef enum {
|
|
|
Current_Export ,
|
|
@@ -1447,7 +1451,6 @@ void CheckSystemValue(void)
|
|
|
if((access(filenmae,F_OK))!=-1)
|
|
|
{
|
|
|
DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
|
|
|
-
|
|
|
sprintf(str,"rm -f %s",filenmae);
|
|
|
system(str);
|
|
|
}
|
|
@@ -1472,7 +1475,6 @@ void CheckSystemValue(void)
|
|
|
sprintf(str,"rm -f %s",filenmae);
|
|
|
system(str);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}// End for GB
|
|
|
}
|
|
@@ -1495,21 +1497,16 @@ void CheckSystemValue(void)
|
|
|
|
|
|
sprintf(str,"rm -f %s",filenmae);
|
|
|
system(str);
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}//End for AC
|
|
|
|
|
|
-
|
|
|
}//END OF ELSE
|
|
|
|
|
|
+ clientTime.MeterValues[gun_index] = time((time_t*)NULL);
|
|
|
|
|
|
- // sleep(1);
|
|
|
- clientTime.MeterValues[gun_index] = time((time_t*)NULL);
|
|
|
-
|
|
|
- if(meterValueSend[gun_index] == 1)
|
|
|
- sendMeterValuesRequest(gun_index);
|
|
|
+ if(meterValueSend[gun_index] == 1)
|
|
|
+ sendMeterValuesRequest(gun_index);
|
|
|
}
|
|
|
|
|
|
//==============================================
|
|
@@ -1990,6 +1987,13 @@ int sendStartTransactionRequest(int gun_index)
|
|
|
strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].Timestamp, buf);
|
|
|
//strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
|
|
|
+ // clear StartTransaction Response
|
|
|
+ strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ExpiryDate, "");
|
|
|
+ strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag, "");
|
|
|
+ strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "");
|
|
|
+ ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId = 0;
|
|
|
+
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
|
|
|
{
|
|
|
for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
@@ -2049,7 +2053,7 @@ int sendStartTransactionRequest(int gun_index)
|
|
|
sprintf(tempdata, "StartTransaction,%d", (gun_index));
|
|
|
if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
|
|
|
{
|
|
|
- result = PASS;
|
|
|
+ result = PASS;
|
|
|
}
|
|
|
strcpy(queuedata, message);
|
|
|
queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
|
|
@@ -2847,7 +2851,7 @@ int sendMeterValuesRequest(int gun_index)
|
|
|
//int length = 0;
|
|
|
char tempdata[65]={0};
|
|
|
|
|
|
- DEBUG_ERROR("sendMeterValuesRequest ...\n");
|
|
|
+ DEBUG_INFO("sendMeterValuesRequest ...\n");
|
|
|
//DEBUG_ERROR("gun_index =%d\n",gun_index);
|
|
|
|
|
|
if((ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == 0)&&(ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq == 0)) // no TransactionId
|
|
@@ -11155,12 +11159,11 @@ DEBUG_INFO("idTagInfo-status: %s\n", ShmOCPP16Data->StartTransaction[gun_index].
|
|
|
DEBUG_INFO("transactionId: %d\n", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId);
|
|
|
#endif
|
|
|
|
|
|
- if(strcmp((const char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Accepted") == 0)
|
|
|
- {
|
|
|
- //add Charging Record
|
|
|
- SettingChargingRecord(gun_index, transactionIdInt);
|
|
|
-
|
|
|
- }
|
|
|
+ //if(strcmp((const char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Accepted") == 0)
|
|
|
+ //{
|
|
|
+ // //add Charging Record
|
|
|
+ // SettingChargingRecord(gun_index, transactionIdInt);
|
|
|
+ //}
|
|
|
|
|
|
//DEBUG_INFO("Start Charging ErrorCode=%s\n", ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
|
|
|
}
|
|
@@ -11290,12 +11293,12 @@ int initialConfigurationTable(void)
|
|
|
|
|
|
/*Core Profile*/
|
|
|
//AllowOfflineTxForUnknownId
|
|
|
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility = 1;
|
|
|
+ ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility = 0;
|
|
|
printf("AllowoddlineTXForUnknownId type: %d \n", ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility);
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemName, "AllowOfflineTxForUnknownId");
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "FALSE" );
|
|
|
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "false", "FALSE");
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "true", "FALSE");
|
|
|
|
|
|
//AuthorizationCacheEnabled
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility = 1;
|
|
@@ -11417,8 +11420,8 @@ int initialConfigurationTable(void)
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility = 1;
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemName, "MinimumStatusDuration");
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "0" );
|
|
|
-
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","MinimumStatusDuration", "false", "0");
|
|
|
+ server_cycle_Status = 120; //StatusNotification cycle
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","MinimumStatusDuration", "false", "120");
|
|
|
|
|
|
// NumberOfConnectors
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility = 0;
|
|
@@ -11465,9 +11468,9 @@ int initialConfigurationTable(void)
|
|
|
// StopTransactionOnInvalidId
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = 0; //1;
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemName, "StopTransactionOnInvalidId");
|
|
|
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "TRUE" );
|
|
|
+ strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "FALSE" );
|
|
|
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "true", "TRUE");
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "true", "FALSE");
|
|
|
|
|
|
// StopTxnAlignedData
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility = 1;
|
|
@@ -11815,7 +11818,7 @@ int initialConfigurationTable(void)
|
|
|
{
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
|
|
|
sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "%d", atoi(valuestr) );
|
|
|
-
|
|
|
+ server_cycle_Status = atoi(valuestr); //StatusNotification cycle
|
|
|
}
|
|
|
|
|
|
if(strcmp(keystr, "NumberOfConnectors") == 0)
|
|
@@ -12026,7 +12029,7 @@ void StoreConfigurationTable(void)
|
|
|
*/
|
|
|
|
|
|
//DEBUG_INFO("data=%s\n",data);
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData);
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData);
|
|
|
|
|
|
//AuthorizationCacheEnabled
|
|
|
/*
|
|
@@ -12238,12 +12241,12 @@ void StoreConfigurationTable(void)
|
|
|
|
|
|
// StopTransactionOnInvalidId
|
|
|
/*
|
|
|
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = 1;
|
|
|
+ ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = 0;
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemName, "StopTransactionOnInvalidId");
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "FALSE" );
|
|
|
*/
|
|
|
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData);
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData);
|
|
|
|
|
|
// StopTxnAlignedData
|
|
|
/*
|
|
@@ -13650,6 +13653,7 @@ void processUnkownKey(void)
|
|
|
{
|
|
|
//Charger.MinimumStatusDuration = Integer.parseInt(value);
|
|
|
sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "%d", atoi(value) );
|
|
|
+ server_cycle_Status = atoi(value); //StatusNotification Cycle
|
|
|
isSuccess = ConfigurationStatus_Accepted;
|
|
|
}
|
|
|
}
|
|
@@ -15100,6 +15104,12 @@ int GetTransactionId(int gunindex, unsigned char idTag[])
|
|
|
temptransactionId = 0;
|
|
|
/*------ Read the file ----------------*/
|
|
|
fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
|
|
|
+ if (!fptr1)
|
|
|
+ {
|
|
|
+ printf(" File not found or unable to open the input file!!\n");
|
|
|
+ return temptransactionId;
|
|
|
+ }
|
|
|
+
|
|
|
ch=fgetc(fptr1);
|
|
|
//printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
|
|
|
rewind(fptr1);
|
|
@@ -15117,11 +15127,15 @@ int GetTransactionId(int gunindex, unsigned char idTag[])
|
|
|
char *revbuf[8] = {0}; //存放分割後的子字串
|
|
|
int num = 0;//分割後子字串的個數
|
|
|
splitstring(str,",",revbuf,&num); //呼叫函式進行分割
|
|
|
- if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
|
|
|
+ if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
|
|
|
{
|
|
|
- temptransactionId = atoi(revbuf[2]);
|
|
|
- break;
|
|
|
+ if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
|
|
|
+ {
|
|
|
+ temptransactionId = atoi(revbuf[2]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -15143,15 +15157,15 @@ void SetTransactionIdZero(int transactionId)
|
|
|
fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
|
|
|
if (!fptr1)
|
|
|
{
|
|
|
- printf(" File not found or unable to open the input file!!\n");
|
|
|
- return ;
|
|
|
+ printf(" File not found or unable to open the input file!!\n");
|
|
|
+ return ;
|
|
|
}
|
|
|
fptr2 = fopen(temp, "w"); // open the temporary file in write mode
|
|
|
if (!fptr2)
|
|
|
{
|
|
|
- printf("Unable to open a temporary file to write!!\n");
|
|
|
- fclose(fptr1);
|
|
|
- return ;
|
|
|
+ printf("Unable to open a temporary file to write!!\n");
|
|
|
+ fclose(fptr1);
|
|
|
+ return ;
|
|
|
}
|
|
|
|
|
|
ch=fgetc(fptr1);
|