Skip to content
Snippets Groups Projects
Commit 7ea40adb authored by Nithya's avatar Nithya
Browse files
Milliseconds updated on SU
parent 4e2dd40e
No related branches found
No related tags found
1 merge request!374Resolve TMSS-494
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
/* eslint-disable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */
import React, {useEffect, useRef} from 'react'; import React, {useEffect, useRef} from 'react';
import _ from 'lodash'; import _ from 'lodash';
import flatpickr from 'flatpickr';
import UnitConverter from '../../utils/unit.converter' import UnitConverter from '../../utils/unit.converter'
import $RefParser from "@apidevtools/json-schema-ref-parser"; import $RefParser from "@apidevtools/json-schema-ref-parser";
import "@fortawesome/fontawesome-free/css/all.css"; import "@fortawesome/fontawesome-free/css/all.css";
import "flatpickr/dist/flatpickr.css"; import "flatpickr/dist/flatpickr.css";
import UtilService from '../../services/util.service';
const JSONEditor = require("@json-editor/json-editor").JSONEditor; const JSONEditor = require("@json-editor/json-editor").JSONEditor;
function Jeditor(props) { function Jeditor(props) {
...@@ -267,7 +265,7 @@ function Jeditor(props) { ...@@ -267,7 +265,7 @@ function Jeditor(props) {
"cleave": { "cleave": {
numericOnly: true, numericOnly: true,
blocks: [2, 2, 2, 4], blocks: [2, 2, 2, 4],
delimiters: [':', ':','.'], delimiters: isDegree ? [':', ':','.'] : [':', ':', ':'],
delimiterLazyShow: true delimiterLazyShow: true
} }
} }
...@@ -442,15 +440,15 @@ function Jeditor(props) { ...@@ -442,15 +440,15 @@ function Jeditor(props) {
*/ */
function validateTime(prpOutput) { function validateTime(prpOutput) {
const splitOutput = prpOutput.split(':'); const splitOutput = prpOutput.split(':');
const isMilliSecondsPresent = prpOutput.split('.'); const isMilliSecondsPresent = splitOutput[3];
if (splitOutput.length < 3 || isMilliSecondsPresent.length === 1 || isMilliSecondsPresent[1].length !== 4) { if (splitOutput.length < 3 || (isMilliSecondsPresent[1] && isMilliSecondsPresent[1].length > 4)) {
// if (splitOutput.length < 3) { // if (splitOutput.length < 3) {
return false; return false;
} else { } else {
if (parseInt(splitOutput[0]) > 23 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59 || parseInt(splitOutput[3])>999) { if (parseInt(splitOutput[0]) > 23 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59) {
return false; return false;
} }
const timeValue = parseInt(splitOutput[0]*60*60) + parseInt(splitOutput[1]*60) + parseInt(splitOutput[2]*1000 + parseInt(splitOutput[3])); const timeValue = parseInt(splitOutput[0]*60*60) + parseInt(splitOutput[1]*60) + parseInt(splitOutput[2]*1000);
if (timeValue >= 86400) { if (timeValue >= 86400) {
return false; return false;
} }
...@@ -465,7 +463,7 @@ function Jeditor(props) { ...@@ -465,7 +463,7 @@ function Jeditor(props) {
function validateAngle(prpOutput) { function validateAngle(prpOutput) {
const splitOutput = prpOutput.split(':'); const splitOutput = prpOutput.split(':');
const isMilliSecondsPresent = prpOutput.split('.'); const isMilliSecondsPresent = prpOutput.split('.');
if (splitOutput.length < 3 || isMilliSecondsPresent.length === 1 || isMilliSecondsPresent[1].length !== 4) { if (splitOutput.length < 3 || isMilliSecondsPresent[1].length > 4) {
//if (splitOutput.length < 3) { //if (splitOutput.length < 3) {
return false; return false;
} else { } else {
......
...@@ -70,14 +70,26 @@ const UnitConverter = { ...@@ -70,14 +70,26 @@ const UnitConverter = {
const dd = Math.floor(prpInput * 180 / Math.PI); const dd = Math.floor(prpInput * 180 / Math.PI);
const mm = Math.floor((degrees-dd) * 60); const mm = Math.floor((degrees-dd) * 60);
const ss = +((degrees-dd-(mm/60)) * 3600).toFixed(0); const ss = +((degrees-dd-(mm/60)) * 3600).toFixed(0);
const ssss = round(((degrees - dd - (mm/60) - (ss/3600)) * 3600000), 4) const ssss = round(((degrees - dd - (mm/60) - (ss/3600)) * 36000000), 4);
return (dd<10?`0${dd}`:`${dd}`) + ':' + (mm<10?`0${mm}`:`${mm}`) + ':' + (ss<10?`0${ss}`:`${ss}`) + '.' + (ssss<10?`0${ssss}`:`${ssss}`); let milliSeconds = (ssss * 10000).toString().substr(0,4);
if (milliSeconds < 1) {
milliSeconds = this.padDigits(milliSeconds.substr(1), 4);
} else {
milliSeconds = this.padDigits(milliSeconds, 4);
}
return (dd<10?`0${dd}`:`${dd}`) + ':' + (mm<10?`0${mm}`:`${mm}`) + ':' + (ss<10?`0${ss}`:`${ss}`) + '.' + milliSeconds;
} else { } else {
const hh = Math.floor(degrees/15); const hh = Math.floor(degrees/15);
const mm = Math.floor((degrees - (hh*15))/15 * 60 ); const mm = Math.floor((degrees - (hh*15))/15 * 60 );
const ss = +((degrees -(hh*15)-(mm*15/60))/15 * 3600).toFixed(0); const ss = +((degrees -(hh*15)-(mm*15/60))/15 * 3600).toFixed(0);
const ssss = round(((degrees - (hh*15) - (mm/4) - (ss/240)) *240000),4); const ssss = round(((degrees - (hh*15) - (mm/4) - (ss/240)) *2400000),4);
return (hh<10?`0${hh}`:`${hh}`) + ':' + (mm<10?`0${mm}`:`${mm}`) + ':' + (ss<10?`0${ss}`:`${ss}`) + ':' + (ssss<10?`0${ssss}`:`${ssss}`); let milliSeconds = (ssss * 10000).toString().substr(0,4);
if (milliSeconds < 1) {
milliSeconds = this.padDigits(milliSeconds.substr(1), 4);
} else {
milliSeconds = this.padDigits(milliSeconds, 4);
}
return (hh<10?`0${hh}`:`${hh}`) + ':' + (mm<10?`0${mm}`:`${mm}`) + ':' + (ss<10?`0${ss}`:`${ss}`) + ':' + milliSeconds;
} }
} else { } else {
return "00:00:00"; return "00:00:00";
...@@ -90,15 +102,24 @@ const UnitConverter = { ...@@ -90,15 +102,24 @@ const UnitConverter = {
getAngleOutput(prpOutput, isDegree) { getAngleOutput(prpOutput, isDegree) {
if(prpOutput){ if(prpOutput){
const splitOutput = prpOutput.split(':'); const splitOutput = prpOutput.split(':');
const milliSeconds = prpOutput.split('.')[1] || '0000';
if (isDegree) { if (isDegree) {
return ((splitOutput[0]*1 + splitOutput[1]/60 + splitOutput[2]/3600 + splitOutput[3]/3600000)*Math.PI/180); return ((splitOutput[0]*1 + splitOutput[1]/60 + splitOutput[2].split('.')[0]/3600 + milliSeconds/36000000)*Math.PI/180);
} else { } else {
return ((splitOutput[0]*15 + splitOutput[1]/4 + splitOutput[2]/240 + splitOutput[3]/240000)*Math.PI/180); return ((splitOutput[0]*15 + splitOutput[1]/4 + splitOutput[2]/240 + splitOutput[3]/2400000)*Math.PI/180);
} }
}else{ }else{
return "00:00:00.0000"; return "00:00:00.0000";
} }
},
/**
* Function to add leading zeros in end
* @param {*} number
* @param {*} digits
*/
padDigits(number, digits) {
return number + Array(Math.max(digits - String(number).length + 1, 0)).join(0);
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment