Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AsithaIndrajith committed Dec 9, 2019
1 parent 30df326 commit 62d28a8
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 48 deletions.
41 changes: 35 additions & 6 deletions src/views/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Dashboard extends React.Component {
sections: []
}
],
branch: "",
branch: "Negambo",
faultyPathSwithces: [],
faultyPathSections: [],
ButtonCaption: "View Structural Map",
Expand All @@ -94,6 +94,25 @@ class Dashboard extends React.Component {
this.onChageNewSection = this.onChageNewSection.bind(this);
}

componentDidMount(){
firebase
.database()
.ref()
.child(this.state.branch + "/faultSwitch")
.on("value", snapshot => {
//Do whatever
console.log(snapshot.val());
if(this.state.faultSwitch!==snapshot.val() && snapshot.val()!==""){
Swal.fire({
title: 'Alert',
text: "Fault detected at "+snapshot.val(),
type: 'warning',
})
}

});
}

handleClickOpen = (event, source, target) => {
var affectedNodes = onRightClickLink(
event,
Expand Down Expand Up @@ -303,7 +322,8 @@ class Dashboard extends React.Component {
this.state.faultyPathSwithces,
validSet,
this.state.switch_list,
this.state.switchtable
this.state.switchtable,
this.state.faultSwitch
);

this.setState({
Expand Down Expand Up @@ -365,11 +385,20 @@ class Dashboard extends React.Component {
let isReconfigured = val.reconfigure[this.state.logIndex].isReconfigured
let optimalPath = parseInt(val.reconfigure[this.state.logIndex].optimalPath[0], 10)
let reconfigurePaths = JSON.parse(val.reconfigure[this.state.logIndex].reconfiguredPaths)
let faultPath = JSON.parse(val.reconfigure[this.state.logIndex].faultyPath)
console.log(reconfigurePaths)
if(!isRepaired){
faultLoc = JSON.parse(val.reconfigure[this.state.logIndex].faultySection)[0]
faultFeeder = JSON.parse(val.reconfigure[this.state.logIndex].faultyFeeder)[0]
}

let fpS = []
let fpE = []

for(let g=0;g<faultPath.length;g++){
fpS.push(faultPath[g][0])
fpE.push(faultPath[g][1])
}

//Map State
// this.setState({
Expand All @@ -394,8 +423,8 @@ class Dashboard extends React.Component {
this.state.noopensw_list,
this.state.switch_list,
this.state.section_list,
this.state.faultyPathSwithces,
this.state.faultyPathSections,
fpS,
fpE,
this.state.switchtable,
this.state.faultSwitch,
this.state.allFaultPaths,
Expand All @@ -412,8 +441,8 @@ class Dashboard extends React.Component {
this.state.noopensw_list,
this.state.switch_list,
this.state.section_list,
this.state.faultyPathSwithces,
this.state.faultyPathSections,
fpS,
fpE,
this.state.switchtable,
this.state.faultSwitch,
this.state.allFaultPaths,
Expand Down
41 changes: 27 additions & 14 deletions src/views/Dashboard/drawMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ const drawGraph = (faultyFeeder, faultLoc, feed_list, noopn_list, sw_list, se_li
}

//let f1 = faultyPathSwithces.indexOf(sw_list.indexOf(faultLoc[0]))
let f2 = faultyPathSwithces.indexOf(sw_list.indexOf(faultLoc[1]))
let f2 = faultLoc[1]!=="-1"?faultyPathSwithces.indexOf(sw_list.indexOf(faultLoc[1])):faultyPathSwithces.indexOf(sw_list.indexOf(faultLoc[0]))
let faultSec = se_list[faultyPathSections[f2]]
// let fpath = JSON.parse(JSON.stringify(faultyPathSections))
// let recfNode = optimalPath[0][0]
// let recfSec = optimalPath[0][1]
// let newFaultPath = fpath.splice(f2+1, fpath.length)
let fpath = JSON.parse(JSON.stringify(faultyPathSections))
let newFaultPath = fpath.splice(f2+1, fpath.length)
//console.log(newFaultPath)

//console.log("Fault section---------> "+faultSec)
let recfinNodeSec = []
for(let i=0;i<sw_list.length;i++){
if(mapState[sw_list[i]]===1 && noopn_list.includes(sw_list[i])){
recfinNodeSec = getSectionOfSwitch(switchtable, sw_list[i])

}
}


for(let i=0;i<sw_list.length;i++){
let typeofnode = ""
Expand Down Expand Up @@ -101,25 +107,32 @@ const drawGraph = (faultyFeeder, faultLoc, feed_list, noopn_list, sw_list, se_li
}
}else{
for(let j=0;j<section_list.length;j++){


if(faultSec===section_list[j]){
link_color = "#654321"
}else{
// link_color = "#6fff6f"
link_color = "#6fff6f"
}
if(faultyPathSections.includes(se_list.indexOf(section_list[j]))){
if(newFaultPath.includes(se_list.indexOf(section_list[j]))){
link_color = "#654321"
}else{
link_color = "#6fff6f"
}


if(mapState[sw_list[i]]===1 && noopn_list.includes(sw_list[i])){
let recfinNodeSec = getSectionOfSwitch(switchtable, sw_list[i])
if(recfinNodeSec.includes(section_list[j])){
if(faultLoc[1]==="-1"){
link_color = "#6fff6f"
}else{
//
}

}

console.log(recfinNodeSec)
console.log(section_list[j])
if(recfinNodeSec.includes(section_list[j])){
link_color = "#6fff6f"
}else{
//
}

link_arr.push({source: id, target: section_list[j], color: link_color})

}
Expand Down
88 changes: 60 additions & 28 deletions src/views/Dashboard/faultFinder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {findFeederInRow, findFeederInCol, getRow, rowOperation, colOperation, getSwitchsToSwitch, getSwitchCurrent, getSectionOfSwitch} from "./matrixOperations"
import {findFeederInRow, findFeederInCol, getRow, rowOperation, colOperation, getSwitchCurrent, getSectionOfSwitch} from "./matrixOperations"
var firebase = require("firebase");

const findFaultyFeeder = (faultSwitch, feedMatrix, switch_list, feed_list, section_list, switchtable) => {
Expand Down Expand Up @@ -149,38 +149,70 @@ const findFaultyFeeder = (faultSwitch, feedMatrix, switch_list, feed_list, secti

}

const getFaultLoc = (faultyPath, validset, switch_list, switch_table) => {
const getFaultLoc = (faultyPath, validset, switch_list, switch_table, faultSwitch) => {
console.log("==================================================")
console.log(validset)
faultyPath = [...new Set(faultyPath)]
let FPLength = faultyPath.length

let loc = []
for(let i=0;i<validset.length;i++){
let tempLoc = []
tempLoc.push(validset[i])
let tempID = switch_list.indexOf(validset[i])
if(FPLength>faultyPath.indexOf(tempID)+1){
let endLoc = switch_list[faultyPath[faultyPath.indexOf(tempID)+1]]
tempLoc.push(endLoc)
loc.push(tempLoc)
console.log(validset.length)
console.log("==================================================")
let tempploc = []
if(validset.length>0){
let end = validset[validset.length-1]
console.log(end)
let endIndex = faultyPath.lastIndexOf(switch_list.indexOf(end))
console.log(endIndex)

let next = faultyPath[endIndex+1]
if(next!==undefined){
tempploc.push([end,switch_list[next]])
}else{
tempploc.push([end,"-1"])
}
console.log(next)
}else{
let end = faultSwitch
let endIndex = faultyPath.lastIndexOf(switch_list.indexOf(end))
let next = faultyPath[endIndex+1]
if(next!==undefined){
tempploc.push([end,switch_list[next]])
}else{
tempLoc.push(validset[i])
loc.push(tempLoc)
let arr = getSwitchsToSwitch(switch_list,validset[i],switch_table)
for(let j=0;j<faultyPath.length;j++){
if(arr.includes(switch_list[faultyPath[j]])){
console.log(switch_list[faultyPath[j]])
console.log(j)
arr.splice(arr.indexOf(switch_list[faultyPath[j]]), 1)
}
}
console.log(arr)
tempploc.push([end,"-1"])
}
console.log(next)
}
console.log(tempploc)


// faultyPath = [...new Set(faultyPath)]
// let FPLength = faultyPath.length

// let loc = []
// for(let i=0;i<validset.length;i++){
// let tempLoc = []
// tempLoc.push(validset[i])
// let tempID = switch_list.indexOf(validset[i])
// if(FPLength>faultyPath.indexOf(tempID)+1){
// let endLoc = switch_list[faultyPath[faultyPath.indexOf(tempID)+1]]
// tempLoc.push(endLoc)
// loc.push(tempLoc)
// }else{
// tempLoc.push(validset[i])
// loc.push(tempLoc)
// let arr = getSwitchsToSwitch(switch_list,validset[i],switch_table)
// for(let j=0;j<faultyPath.length;j++){
// if(arr.includes(switch_list[faultyPath[j]])){
// console.log(switch_list[faultyPath[j]])
// console.log(j)
// arr.splice(arr.indexOf(switch_list[faultyPath[j]]), 1)
// }
// }
// console.log(arr)
// }


}
console.log(loc)
return loc
// }
// console.log(loc)
// return loc
return tempploc
}


Expand Down
1 change: 1 addition & 0 deletions src/views/Dashboard/reconfigure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var firebase = require("firebase");
const findEndConnectedNOs = (faultLoc, noList, switch_table, switch_list) => {
let nos = []
for(let j=0;j<faultLoc.length;j++){
if(faultLoc[j][1]==="-1")continue
let end = faultLoc[j][1]
let arr = getSwitchsToSwitch(switch_list,end,switch_table)
let arrLen = arr.length
Expand Down
3 changes: 3 additions & 0 deletions src/views/Logs/Logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class PhysicalConnectivity extends React.Component {
let details = []
let dts = <div>Fault switch is {faultSwitch}. Faulty Feeder is {faultyFeeder[0]}. Fault section is {JSON.stringify(faultySection[0])}.</div>
details.push(dts)
details.push(<div>
<Button color='warning' onClick={()=>this.isolateBtnHandler(faultySection[0],faultyFeeder[0], this.state.mapState,this.state.branch, isFaultRepaired, i)}> Isolate </Button>
</div>)
let row = [time, details, <Button color={isFaultRepaired?"success":"default"} onClick={()=>this.repairedBtnHandler(i, isFaultRepaired)}>{isFaultRepaired?<div>Restored <CheckIcon/></div>:"Restore"}</Button>]
tableData.push(row)
}
Expand Down

0 comments on commit 62d28a8

Please sign in to comment.