|
@@ -200,13 +200,50 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
if (_request.meterValue.Count > 0)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
using (var db = new MeterValueDBContext())
|
|
|
{
|
|
|
foreach (var item in _request.meterValue)
|
|
|
{
|
|
|
+ int registerCount = item.sampledValue.Where(x => x.measurand == Measurand.Energy_Active_Import_Register).ToList().Count;
|
|
|
+ if (registerCount > 0)
|
|
|
+ {
|
|
|
+ string voltage_text = item.sampledValue.Where(x => x.measurand == Measurand.Voltage).Select(x => x.value).FirstOrDefault();
|
|
|
+ decimal voltage = decimal.Parse(voltage_text);
|
|
|
+ string current_text = item.sampledValue.Where(x => x.measurand == Measurand.Current_Import).Select(x => x.value).FirstOrDefault();
|
|
|
+ decimal current = decimal.Parse(current_text);
|
|
|
+ decimal meterStart = 0;
|
|
|
+ string energyRegister_text = item.sampledValue.Where(x => x.measurand == Measurand.Energy_Active_Import_Register).Select(x => x.value).FirstOrDefault();
|
|
|
+ decimal energyRegister = decimal.Parse(energyRegister_text);
|
|
|
+ using (var maindb = new MainDBContext())
|
|
|
+ {
|
|
|
+ meterStart = maindb.TransactionRecord.Where(x => x.Id == _request.transactionId.Value).Select(x => x.MeterStart).FirstOrDefault();
|
|
|
+ }
|
|
|
+
|
|
|
+ item.sampledValue.Add(new SampledValue()
|
|
|
+ {
|
|
|
+ context = ReadingContext.Sample_Periodic,
|
|
|
+ format = ValueFormat.Raw,
|
|
|
+ location = Location.Outlet,
|
|
|
+ phase = Phase.L1_N,
|
|
|
+ unit = UnitOfMeasure.kWh,
|
|
|
+ measurand = Measurand.Energy_Active_Import_Interval,
|
|
|
+ value = decimal.Divide(decimal.Subtract(energyRegister, meterStart), (decimal)1000).ToString()
|
|
|
+ });
|
|
|
+ item.sampledValue.Add(new SampledValue()
|
|
|
+ {
|
|
|
+ context = ReadingContext.Sample_Periodic,
|
|
|
+ format = ValueFormat.Raw,
|
|
|
+ location = Location.Outlet,
|
|
|
+ phase = Phase.L1_N,
|
|
|
+ unit = UnitOfMeasure.kW,
|
|
|
+ measurand = Measurand.Power_Active_Import,
|
|
|
+ value = decimal.Divide(decimal.Multiply(voltage, current), (decimal)1000).ToString()
|
|
|
+ });
|
|
|
+ }
|
|
|
foreach (var sampleVaule in item.sampledValue)
|
|
|
{
|
|
|
-
|
|
|
decimal value = Convert.ToDecimal(sampleVaule.value);
|
|
|
|
|
|
if (sampleVaule.context == ReadingContext.Sample_Periodic && sampleVaule.measurand == Measurand.Energy_Active_Import_Interval)
|
|
@@ -391,13 +428,13 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
_idTagInfo = new IdTagInfo() { expiryDate = DateTime.UtcNow.AddDays(1), status = AuthorizationStatus.Accepted };
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
using (var db = new MainDBContext())
|
|
|
{
|
|
|
var transaction = db.TransactionRecord.Where(x => x.Id == _request.transactionId
|
|
|
&& x.ChargeBoxId == session.ChargeBoxId).FirstOrDefault();
|
|
|
-
|
|
|
+
|
|
|
if (transaction != null)
|
|
|
{
|
|
|
_ConnectorId = transaction.ConnectorId;
|
|
@@ -683,7 +720,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
}
|
|
|
if (bill.Count > 1)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
confirmbill.Add(bill.Where(x => x.StartTime == startTime.ToString("HH:00")).FirstOrDefault());
|
|
|
if (confirmbill.Count == 24) break;
|
|
|
//if (confirmbill.Count > 1)
|