Skip to content

Commit

Permalink
Refactoring and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Gustafsson committed Aug 13, 2024
1 parent a72d670 commit fa74cd4
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* A class that dispalays some common parts of a result
*/

export default class CommonPropertyView {
constructor (propList, context, resultManager) {
this.background = document.createElement('div')
Expand All @@ -17,7 +21,9 @@ export default class CommonPropertyView {
}

/**
* Run everytime the tab is opened
* Display some common parameters from a result. Run everytime the tab is opened, or a result is recieved
* @param {*} result a recieved result
* @param {*} propList a list of '.' separated paths to properties in a result
*/
displayProps (result, propList) {
this.keys.innerHTML = ''
Expand All @@ -43,9 +49,6 @@ export default class CommonPropertyView {
line2.innerText = value // eslint-disable-line
this.values.appendChild(line2)
}

// const maxes = result.getTaggedValues(8)
// console.log(maxes)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* A class that displays the most important tightening related values of a result
*/
export default class IJTPropertyView {
constructor (context, resultManager) {
this.background = document.createElement('div')
Expand All @@ -23,7 +26,10 @@ export default class IJTPropertyView {
}

/**
* Display some tightening specific values in a result.
* Run everytime the tab is opened
* @param {*} result a result
* @returns Nothing
*/
displayProps (result) {
function makeHeading (text) {
Expand All @@ -44,7 +50,7 @@ export default class IJTPropertyView {
return
}

const finals = content.getTaggedValues(1)
const finals = content.getTaggedValues(1) // Get all reported values with ValueTag === 1 (Final)

this.name.appendChild(makeHeading('Value'))
this.low.appendChild(makeHeading('Low'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export default class USDemo extends BasicScreen {
return
}

// console.log(this.settings.productId)

const values = [
{
value: this.settings.productId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import BasicScreen from '../GraphicSupport/BasicScreen.mjs' // Basic functionality application code for the screen functionality
import BasicScreen from './BasicScreen.mjs' // Basic functionality application code for the screen functionality

/**
* The purpose of this class is to generate an HTML representation of tightening selection and basic
* display of a result for OPC UA Industrial Joining Technologies communication
*/
* The purpose of this class is to generate an GUI
* for editing settings used elsewhere in the app
**/
export default class Settings extends BasicScreen {
constructor (webSocketManager) {
super('Settings', 'tighteningsystem')
Expand Down Expand Up @@ -68,11 +68,18 @@ export default class Settings extends BasicScreen {
this.container = editArea

this.createButton('Save', this.displayArea, () => {
this.settings.productid = this.productId
this.settings.button1selection = this.JoiningProcess1
this.settings.button2selection = this.JoiningProcess2
this.settings.initialviewlevel = this.initialViewLevel

if (this.productId) {
this.settings.productid = this.productId
}
if (this.JoiningProcess1) {
this.settings.button1selection = this.JoiningProcess1
}
if (this.JoiningProcess2) {
this.settings.button2selection = this.JoiningProcess2
}
if (this.initialViewLevel) {
this.settings.initialviewlevel = this.initialViewLevel
}
this.webSocketManager.send('set settings', null, null, this.settings)
})

Expand All @@ -85,11 +92,21 @@ export default class Settings extends BasicScreen {
if (msg.productid || msg.initialviewlevel
) {
this.settings = msg
this.productId = msg.productid
this.JoiningProcess1 = msg.button1selection
this.JoiningProcess2 = msg.button2selection
this.methodDefaults = msg.methoddefaults
this.initialViewLevel = msg.initialviewlevel
if (msg.productid) {
this.productId = msg.productid
}
if (msg.button1selection) {
this.JoiningProcess1 = msg.button1selection
}
if (msg.button2selection) {
this.JoiningProcess2 = msg.button2selection
}
if (msg.methoddefaults) {
this.methodDefaults = msg.methoddefaults
}
if (msg.initialviewlevel) {
this.initialViewLevel = msg.initialviewlevel
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ export default class TabGenerator {
* @param {Object} content The graphical representation of the content, preferably a descendent of the BasicScreen class
* @returns
*/
generateTab (content, viewLevel) {
this.containerList.push(new Tab(this.contentDiv, content, this.selector, viewLevel, this.currentViewLevel))
generateTab (content, viewLevel, selected) {
const tab = new Tab(this.contentDiv, content, this.selector, viewLevel, this.currentViewLevel)
tab.select()
this.containerList.push(tab)
// If it is the first, then show it
// if (this.containerList.length === 1) {
// this.containerList[0].select()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* The purpose of this class is to display a GUI for filling in arguments and calling a method
*/
export default class MethodGUICreator {
constructor (screen, methodManager, entityManager, settings) {
this.methodManager = methodManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BasicScreen from '../GraphicSupport/BasicScreen.mjs'
import EndpointGraphics from './EndpointGraphics.mjs'
import EndpointGraphics from '../EndpointTab/EndpointGraphics.mjs'

/**
* The purpose of this class is to generate a webpage that shows a list of OPC UA servers that the user is interested in
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class ServerGraphics extends BasicScreen {
function connect (point, endpointTabGenerator) {
const newConnection = new EndpointGraphics(point.name, settings)
newConnection.instantiate(point.address, socket)
endpointTabGenerator.generateTab(newConnection, true)
endpointTabGenerator.generateTab(newConnection, 1, true)
}

function disconnect (point, endpointTabGenerator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"productid": "www.atlascopco.com/CABLE-B0000000-",
"button1selection": "ProgramIndex_1",
"button2selection": "ProgramIndex_2",
"initialviewlevel": "4",
"initialviewlevel": "1",
"methoddefaults": {
"ns=1;s=TighteningSystem/Simulations/SimulateResults/SimulateSingleResult": {
"arguments": [
Expand Down
5 changes: 3 additions & 2 deletions OPC_UA_Clients/Release2/IJT_Web_Client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

import ServerGraphics from 'views/Servers/ServerGraphics.mjs'
import TabGenerator from 'views/GraphicSupport/TabGenerator.mjs'
import EndpointGraphics from 'views/Servers/EndpointGraphics.mjs'
import Settings from 'views/Servers/Settings.mjs'
import EndpointGraphics from 'views/EndpointTab/EndpointGraphics.mjs'
import Settings from 'views/GraphicSupport/Settings.mjs'


let connection = false
Expand All @@ -59,6 +59,7 @@
container.appendChild(label)

container.select = document.createElement('select')
container.select.classList.add('mainDropDown')
container.appendChild(container.select)

const viewLevels = [['Basic', 1], ['Simple', 2], ['Detailed', 3], ['Specialized', 4], ['Settings', 5]]
Expand Down
6 changes: 5 additions & 1 deletion OPC_UA_Clients/Release2/IJT_Web_Client/nodeStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ html {

.tabright {
flex-basis: content;
align-self: end;
align-self: center;
}

.topRow {
Expand Down Expand Up @@ -1073,3 +1073,7 @@ html {
.myCheckBox {
margin-left: 0px;
}

.mainDropDown {
background-color: lightgray;
}

0 comments on commit fa74cd4

Please sign in to comment.