Skip to content

Commit

Permalink
ev data coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
adenjonah committed May 20, 2024
1 parent 443095e commit 685d278
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 36 deletions.
2 changes: 1 addition & 1 deletion server/json_databases/geojson/nav_path.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-95.08171731249612, 29.564801074268402], [-95.0817141067597, 29.564811937283455], [-95.08171086272411, 29.564820933377636], [-95.08170758295314, 29.564828187529002], [-95.08170427001075, 29.564833824715617], [-95.08170092646077, 29.564837969915533], [-95.08169755486712, 29.56484074810683], [-95.08169415779363, 29.56484228426754], [-95.08169073780422, 29.564842703375746], [-95.08168729746276, 29.564842130409495], [-95.08168383933314, 29.56484069034686], [-95.0816803659792, 29.564838508165884], [-95.08167687996485, 29.564835708844644], [-95.08167338385395, 29.56483241736119], [-95.08166988021043, 29.564828758693587], [-95.08166637159812, 29.564824857819886], [-95.08166286058089, 29.564820839718163], [-95.08165934972266, 29.564816829366464], [-95.08165584158729, 29.564812951742855], [-95.08165233873865, 29.564809331825398], [-95.08164884374064, 29.564806094592146], [-95.08164535915712, 29.564803365021174], [-95.08164188746349, 29.5648012637773], [-95.08163842910004, 29.564799812321272], [-95.08163498247184, 29.564798932909703], [-95.08163154589556, 29.56479854348599], [-95.08162811768784, 29.56479856199354], [-95.0816246961653, 29.56479890637575], [-95.08162127964461, 29.56479949457602], [-95.08161786644239, 29.564800244537746], [-95.08161445487525, 29.564801074204336], [-95.08161104325988, 29.564801901519186], [-95.08160762991291, 29.56480264442569], [-95.08160421330149, 29.5648032282051], [-95.081600793203, 29.564803642005018], [-95.0815973700694, 29.564803907857442], [-95.08159394435826, 29.56480404806616], [-95.08159051652716, 29.564804084934934], [-95.0815870870336, 29.56480404076754], [-95.08158365633514, 29.56480393786775], [-95.08158022488936, 29.56480379853934], [-95.08157679315381, 29.564803645086087], [-95.08157336158604, 29.564803499811756], [-95.08156993064358, 29.564803385020124], [-95.08156650068327, 29.564803318104588], [-95.081563071659, 29.56480329681703], [-95.08155964342389, 29.564803313998958], [-95.08155621583113, 29.564803362491872], [-95.08155278873383, 29.564803435137296], [-95.08154936198517, 29.56480352477672], [-95.08154593543829, 29.564803624251667], [-95.08154250894631, 29.56480372640363], [-95.08153908236244, 29.564803824074122], [-95.08153565553978, 29.564803910104647], [-95.08153222833222, 29.56480397737184], [-95.08152880068081, 29.56480402300268], [-95.08152537269598, 29.564804052378943], [-95.08152194450751, 29.56480407183082], [-95.0815185162453, 29.564804087688522], [-95.0815150880392, 29.564804106282235], [-95.08151166001902, 29.564804133942168], [-95.08150823231462, 29.564804176998514], [-95.0815048050559, 29.564804241781466], [-95.08150137837265, 29.56480433462124], [-95.08149795239473, 29.56480446184802], [-95.08149452724155, 29.56480462928175], [-95.08149110279173, 29.564804831006377], [-95.0814876786832, 29.56480504936986], [-95.08148425454343, 29.56480526620989], [-95.08148082999986, 29.56480546336418], [-95.08147740467994, 29.56480562267042], [-95.08147397821116, 29.564805725966306], [-95.08147055022096, 29.564805755089537], [-95.08146712033678, 29.564805691877815], [-95.08146368818609, 29.564805518168832], [-95.08146025339634, 29.56480521580029], [-95.08145681571682, 29.56480477254998], [-95.08145337595734, 29.564804227896495], [-95.08144993547367, 29.56480364793884], [-95.08144649562618, 29.56480309899602], [-95.08144305777519, 29.564802647387044], [-95.08143962328101, 29.56480235943093], [-95.08143619350398, 29.564802301446676], [-95.08143276980441, 29.56480253975329], [-95.08142935354266, 29.5648031406698], [-95.08142594607902, 29.564804170515192], [-95.08142254877386, 29.564805695608484], [-95.08141916253454, 29.56480776018733], [-95.08141578645672, 29.56481032016395], [-95.08141241918314, 29.564813309369217], [-95.08140905935649, 29.564816661633987], [-95.0814057056195, 29.56482031078914], [-95.08140235661493, 29.564824190665533], [-95.08139901098544, 29.564828235094037], [-95.08139566737378, 29.564832377905525], [-95.0813923244227, 29.56483655293085], [-95.08138898077485, 29.56484069400089], [-95.08138563507747, 29.564844735164172], [-95.08138228651798, 29.564848636806275], [-95.08137893533296, 29.564852410463267], [-95.08137558187964, 29.564856073548086], [-95.08137222651519, 29.564859643473653], [-95.08136886959676, 29.5648631376529], [-95.08136551148156, 29.564866573498758], [-95.08136215252676, 29.564869968424155], [-95.08135879308954, 29.564873339842023], [-95.08135543352707, 29.564876705165286], [-95.08135207419654, 29.56488008180688], [-95.0813487154462, 29.564883486744414], [-95.0813453574189, 29.56488692694305], [-95.08134200005216, 29.564890399355534], [-95.08133864327453, 29.564893900499282], [-95.08133528701458, 29.564897426891697], [-95.08133193120086, 29.5649009750502], [-95.08132857576196, 29.564904541492204], [-95.08132522062643, 29.564908122735122], [-95.08132186572283, 29.564911715296372], [-95.08131851097971, 29.564915315693366], [-95.08131515632567, 29.564918920443514], [-95.08131180168927, 29.564922526064233], [-95.08130844699906, 29.564926129072944], [-95.08130509218358, 29.56492972598705], [-95.08130173717144, 29.56493331332397], [-95.08129838189119, 29.564936887601114], [-95.08129502627136, 29.564940445335903], [-95.08129167024057, 29.564943983045747], [-95.08128831372734, 29.56494749724806], [-95.08128495666026, 29.564950984460257], [-95.08128159896788, 29.564954441199756], [-95.08127824057877, 29.56495786398396]]}, "properties": {"name": "Rover Path"}}]}
80 changes: 55 additions & 25 deletions src/pages/constant/EVData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,79 @@ const EVData = ({ evNumber }) => {

// List of parameters and values in desired order
const parameterList = [
{ key: 'batt_time_left', label: 'Battery Time Left' },
{ key: 'oxy_pri_storage', label: 'Oxygen Primary Storage' },
{ key: 'oxy_sec_storage', label: 'Oxygen Secondary Storage' },
{ key: 'oxy_pri_pressure', label: 'Oxygen Primary Pressure' },
{ key: 'oxy_sec_pressure', label: 'Oxygen Secondary Pressure' },
{ key: 'oxy_time_left', label: 'Oxygen Time Left' },
{ key: 'heart_rate', label: 'Heart Rate' },
{ key: 'oxy_consumption', label: 'Oxygen Consumption' },
{ key: 'co2_production', label: 'CO2 Production' },
{ key: 'suit_pressure_oxy', label: 'Suit Pressure O2' },
{ key: 'suit_pressure_co2', label: 'Suit Pressure CO2' },
{ key: 'suit_pressure_other', label: 'Suit Pressure Other' },
{ key: 'suit_pressure_total', label: 'Suit Pressure Total' },
{ key: 'fan_pri_rpm', label: 'Fan Primary RPM' },
{ key: 'fan_sec_rpm', label: 'Fan Secondary RPM' },
{ key: 'helmet_pressure_co2', label: 'Helmet Pressure CO2' },
{ key: 'scrubber_a_co2_storage', label: 'Scrubber A CO2 Storage' },
{ key: 'scrubber_b_co2_storage', label: 'Scrubber B CO2 Storage' },
{ key: 'temperature', label: 'Temperature' },
{ key: 'coolant_ml', label: 'Coolant ml' },
{ key: 'coolant_gas_pressure', label: 'Coolant Gas Pressure' },
{ key: 'coolant_liquid_pressure', label: 'Coolant Liquid Pressure' },
{ key: 'batt_time_left', label: 'Battery Time Left', min: 3600, max: 10800 },
{ key: 'oxy_pri_storage', label: 'Oxygen Primary Storage', min: 20, max: 100 },
{ key: 'oxy_sec_storage', label: 'Oxygen Secondary Storage', min: 20, max: 100 },
{ key: 'oxy_pri_pressure', label: 'Oxygen Primary Pressure', min: 600, max: 3000 },
{ key: 'oxy_sec_pressure', label: 'Oxygen Secondary Pressure', min: 600, max: 3000 },
{ key: 'oxy_time_left', label: 'Oxygen Time Left', min: 3600, max: 21600 },
{ key: 'coolant_storage', label: 'Coolant Storage', min: 80, max: 100 },
{ key: 'heart_rate', label: 'Heart Rate', min: 50, max: 160 },
{ key: 'oxy_consumption', label: 'Oxygen Consumption', min: 0.05, max: 0.15 },
{ key: 'co2_production', label: 'CO2 Production', min: 0.05, max: 0.15 },
{ key: 'suit_pressure_oxy', label: 'Suit Pressure O2', min: 3.5, max: 4.1 },
{ key: 'suit_pressure_co2', label: 'Suit Pressure CO2', min: 0.0, max: 0.1 },
{ key: 'suit_pressure_other', label: 'Suit Pressure Other', min: 0.0, max: 0.5 },
{ key: 'suit_pressure_total', label: 'Suit Pressure Total', min: 3.5, max: 4.5 },
{ key: 'fan_pri_rpm', label: 'Fan Primary RPM', min: 20000, max: 30000 },
{ key: 'fan_sec_rpm', label: 'Fan Secondary RPM', min: 20000, max: 30000 },
{ key: 'helmet_pressure_co2', label: 'Helmet Pressure CO2', min: 0.0, max: 0.15 },
{ key: 'scrubber_a_co2_storage', label: 'Scrubber A CO2 Storage', min: 0.0, max: 60 },
{ key: 'scrubber_b_co2_storage', label: 'Scrubber B CO2 Storage', min: 0.0, max: 60 },
{ key: 'temperature', label: 'Temperature', min: 50, max: 90 },
{ key: 'coolant_liquid_pressure', label: 'Coolant Liquid Pressure', min: 100, max: 700 },
{ key: 'coolant_gas_pressure', label: 'Coolant Gas Pressure', min: 0, max: 700 },
];

// Function to determine the background color based on the value range
const getBackgroundColor = (value, min, max) => {
if (value < min || value > max) {
return 'red';
}
return 'green';
};

// Function to format the value to a fixed number of decimal places
const formatValue = (value) => {
if (typeof value === 'number') {
return value.toFixed(4); // Change the number of decimal places if needed
}
return value;
};

// Split the parameter list into two columns
const midIndex = Math.ceil(parameterList.length / 2);
const firstColumn = parameterList.slice(0, midIndex);
const secondColumn = parameterList.slice(midIndex);

return (
<div className="ev-container">
<h2>EV{evNumber} Data</h2>
<h4>EV{evNumber} Data</h4>
<div className="ev-table-container">
<table className="ev-table">
<tbody>
{firstColumn.map((param, index) => (
<tr key={param.key}>
<td>{param.label}</td>
<td>{evaData[param.key]}</td>
<td
style={{
backgroundColor: getBackgroundColor(evaData[param.key] ?? evaData[`suit_pressure_cO2`], param.min, param.max),
color: 'black',
}}
>
{formatValue(evaData[param.key] ?? evaData[`suit_pressure_cO2`])}
</td>
{secondColumn[index] ? (
<>
<td>{secondColumn[index].label}</td>
<td>{evaData[secondColumn[index].key]}</td>
<td
style={{
backgroundColor: getBackgroundColor(evaData[secondColumn[index].key] ?? evaData[`suit_pressure_cO2`], secondColumn[index].min, secondColumn[index].max),
color: 'black',
}}
>
{formatValue(evaData[secondColumn[index].key] ?? evaData[`suit_pressure_cO2`])}
</td>
</>
) : (
<>
Expand Down
29 changes: 19 additions & 10 deletions src/pages/constant/constant.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.pagecontainer {


#constantpage {
background-color: #cce6ff;
display: flex;
flex-direction: column;
height: 90vh;
width: 100vw;
}

#constantpage {
background-color: #cce6ff;
}

#centerbar {
width: 10%;
height: 80%;
Expand Down Expand Up @@ -44,14 +43,22 @@
height: 100%;
}

#EV1, #ConstantMap, #EV2 {
width: 33.33%;
#EV, #ConstantMap, #UIADCU {
height: 100%;
}

#EV {
width: 40%;
}

#ConstantMap, #UIADCU {
width: 30%;
}

#topbar {
height: 100%;
width: 100%;
max-height: 7vh;
display: flex;
flex-direction: row;
justify-content: space-around;
Expand Down Expand Up @@ -106,14 +113,14 @@
display: flex;
flex-direction: row;
width: 100%;
height: 35vh;
height: 30vh;
margin-bottom: 20px;
}

.bottom-half {
display: flex;
width: calc(100% - 20px);
height: calc(45% - 20px);
height: calc(53% - 20px);
margin: 10px;
}

Expand Down Expand Up @@ -144,8 +151,10 @@

.ev-table th,
.ev-table td {
font-size: medium;
border: 1px solid #ddd;
padding: 8px;
padding-top: 4px;
padding-bottom: 4px;
text-align: left;
box-sizing: border-box;
}
Expand Down

0 comments on commit 685d278

Please sign in to comment.