[chronojump] Ecc-con loss uses only con
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Ecc-con loss uses only con
- Date: Thu, 11 Jul 2019 16:36:26 +0000 (UTC)
commit eb7f206776ad168b533faaef8f08d65b566fd48b
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jul 11 18:36:02 2019 +0200
Ecc-con loss uses only con
src/encoder.cs | 43 +++++++++++++++++++++++++++++++++++++++++++
src/gui/encoder.cs | 30 ++++++++++++++++++++----------
src/json/compujump.cs | 16 +++++++++++-----
3 files changed, 74 insertions(+), 15 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index f9e14a80..5a731668 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -492,6 +492,44 @@ public class EncoderSignal
return conValue;
}
+ public int GetEccConLossByOnlyConPhase(string variable)
+ {
+ double lowest = 100000;
+ double highest = 0;
+ double eccValue = 0;
+ double conValue = 0;
+ bool ecc = true;
+ //int i = 0;
+ foreach (EncoderCurve curve in curves)
+ {
+ if(ecc)
+ {
+ ecc = false;
+ continue;
+ }
+
+ double compareTo = curve.MeanSpeedD;
+ if(variable == Constants.MeanPower)
+ compareTo = curve.MeanPowerD;
+
+ conValue = compareTo;
+ if(compareTo > highest)
+ highest = compareTo;
+ if(compareTo < lowest)
+ lowest = compareTo;
+
+ //LogB.Information(string.Format("Loss ecc/con (by con) of {0}; i: {1} is: {2}",
variable, i++,
+ // Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest),
highest))));
+
+ ecc = true;
+ }
+ return Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest), highest));
+
+ }
+ /*
+ * this method uses ecc and con and calculates the loss by having the average of them for each
repetition
+ * better do only using the con phase (see above method)
+ *
public int GetEccConLoss(string variable)
{
double lowest = 100000;
@@ -499,6 +537,7 @@ public class EncoderSignal
double eccValue = 0;
double conValue = 0;
bool ecc = true;
+ //int i = 0;
foreach (EncoderCurve curve in curves)
{
double compareTo = curve.MeanSpeedD;
@@ -514,11 +553,15 @@ public class EncoderSignal
if( ( (eccValue + conValue) / 2 ) < lowest)
lowest = (eccValue + conValue) / 2;
}
+ //LogB.Information(string.Format("Loss ecc/con (ecc?: {0}) of {1}; i: {2} is: {3}",
ecc.ToString(), variable, i++,
+ // Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest),
highest))));
+
ecc = ! ecc;
}
return Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest), highest));
}
+ */
~EncoderSignal() {}
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a7a7ae10..a973d678 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5141,9 +5141,9 @@ public partial class ChronoJumpWindow
double maxThisSet = -100000;
double minThisSet = 100000;
- //ForCalcs is to calculate avg and loss
- double maxThisSetValid = maxThisSet;
- double minThisSetValid = minThisSet;
+ //only used for loss. For loss only con phase is used
+ double maxThisSetValidAndCon = maxThisSet;
+ double minThisSetValidAndCon = minThisSet;
//know not-discarded phases
double countValid = 0;
double sumValid = 0;
@@ -5164,10 +5164,13 @@ public partial class ChronoJumpWindow
countValid ++;
sumValid += d;
- if(d > maxThisSetValid)
- maxThisSetValid = d;
- if(d < minThisSetValid)
- minThisSetValid = d;
+ if(eccon == "c" || Util.IsEven(count +1)) //par
+ {
+ if(d > maxThisSetValidAndCon)
+ maxThisSetValidAndCon = d;
+ if(d < minThisSetValidAndCon)
+ minThisSetValidAndCon = d;
+ }
}
count ++;
@@ -5508,9 +5511,16 @@ public partial class ChronoJumpWindow
Util.TrimDecimals( (sumSaved / countSaved), decimals) +
" " + units;
- if(maxThisSetValid > 0)
- title += "; Loss: " + Util.TrimDecimals(
- 100.0 * (maxThisSetValid - minThisSetValid) / maxThisSetValid,
decimals) + "%";
+ string lossString = "; Loss: ";
+ if(eccon != "c")
+ lossString = "; Loss (con): "; //on ecc/con use only con for loss calculation
+
+ if(maxThisSetValidAndCon > 0)
+ {
+ title += lossString + Util.TrimDecimals(
+ 100.0 * (maxThisSetValidAndCon - minThisSetValidAndCon) /
maxThisSetValidAndCon, decimals) + "%";
+ LogB.Information(string.Format("Loss at plot: {0}", 100.0 * (maxThisSetValidAndCon -
minThisSetValidAndCon) / maxThisSetValidAndCon));
+ }
title += "]";
layout_encoder_capture_curves_bars_text.SetMarkup(title);
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 869c5c59..40fae25f 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -637,6 +637,7 @@ public class JsonCompujump : Json
// Converts it to a String
String js = json.ToString();
+ LogB.Information("json UploadEncoderData: ", js);
// Writes the json object into the request dataStream
Stream dataStream;
@@ -848,8 +849,8 @@ public class UploadEncoderDataObject
numBySpeed = nSpeed + 1;
numByPower = nPower + 1;
- lossBySpeed = getLoss(curves, byTypes.SPEED);
- lossByPower = getLoss(curves, byTypes.POWER);
+ lossBySpeed = getConLoss(curves, byTypes.SPEED);
+ lossByPower = getConLoss(curves, byTypes.POWER);
}
private void calculeObjectEccCon (ArrayList curves)
@@ -880,8 +881,10 @@ public class UploadEncoderDataObject
numBySpeed = (nSpeed /2) + 1;
numByPower = (nPower /2) + 1;
- lossBySpeed = eSignal.GetEccConLoss(Constants.MeanSpeed);
- lossByPower = eSignal.GetEccConLoss(Constants.MeanPower);
+ //lossBySpeed = eSignal.GetEccConLoss(Constants.MeanSpeed);
+ //lossByPower = eSignal.GetEccConLoss(Constants.MeanPower);
+ lossBySpeed = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanSpeed);
+ lossByPower = eSignal.GetEccConLossByOnlyConPhase(Constants.MeanPower);
}
//constructor called on SQL load
@@ -930,11 +933,12 @@ public class UploadEncoderDataObject
return curveNum;
}
- private int getLoss(ArrayList curves, byTypes by)
+ private int getConLoss(ArrayList curves, byTypes by)
{
double lowest = 100000;
double highest = 0;
+ //int i=0;
foreach (EncoderCurve curve in curves)
{
double compareTo = curve.MeanSpeedD;
@@ -945,6 +949,8 @@ public class UploadEncoderDataObject
lowest = compareTo;
if(compareTo > highest)
highest = compareTo;
+
+ //LogB.Information(string.Format("Loss (con) of {0}; i: {1} is: {2}", by.ToString(),
i++, Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest), highest))));
}
return Convert.ToInt32(Util.DivideSafe(100.0 * (highest - lowest), highest));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]