Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gbmhunter committed Mar 14, 2017
2 parents b0ce78f + 69724be commit 827e18f
Show file tree
Hide file tree
Showing 36 changed files with 732 additions and 468 deletions.
23 changes: 22 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
os:
- linux
language: node_js
node_js:
- "stable"
- "7"
sudo: required
dist: trusty
env:
- NODE_ENV=PROD
before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export CHROME_BIN=/usr/bin/google-chrome; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export DISPLAY=:99.0; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sh -e /etc/init.d/xvfb start; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update ; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y libappindicator1 fonts-liberation; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo dpkg -i google-chrome*.deb; fi
install:
- npm install
before_script:
- npm run build
script:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then jdk_switcher use oraclejdk8; fi
- npm run test
159 changes: 19 additions & 140 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,171 +1,50 @@

# NinjaCalc



#### A embedded engineering calculator suite for doing calculations in a breeze.


- Author: gbmhunter <[email protected]> ([www.mbedded.ninja](http://www.mbedded.ninja))
- Created: 2015-11-02
- Last Modified: 2016-07-03
- Version: v1.3.0
- Last Modified: 2017-03-09
- Version: v2.0.0
- Company: mbedded.ninja
- Project: NinjaTerm
- Language: Java
- IDE: IntelliJ IDEA
- uC Model: n/a
- Computer Architecture: Any
- Operating System: Any
- Documentation Format: n/a
- Language: Javascript (vue.js)/HTML/CSS
- IDE: WebStorm
- Documentation Format: JSDoc
- License: GPLv3


# Motivation

The goal of this is to provide a easy-to-use web application to help you with all those small, frequent calculations you do while doing embedded engineering (or other forms of engineering). Whether it be a low-pass LC filter, a resistor divider, trying to find PCB track current, or even just Ohm's law (o.k., I hope you don't forget that one, but it is included none-the-less), this app makes them easy to find, use, and have confidence in the answers.

The goal of this is to provide a easy-to-use desktop application to help you with all those small, frequent calculations you do while doing embedded engineering (or other forms of engineering). Whether it be a low-pass LC filter, a resistor divider, trying to find PCB track current, or even just Ohm's law (o.k., I hope you don't forget that one, but it is included none-the-less), this app makes them easy to find, use, and have confidence in the answers.
# To Use

Go to http://ninja-calc.mbedded.ninja/

# Features


See the [project home page](http://mbedded-ninja.github.io/NinjaCalc/) for a list of features.


# Installation


1. Download the latest installer-based release from [http://mbedded-ninja.github.io/NinjaCalc/](http://mbedded-ninja.github.io/NinjaCalc/).
2. Run the installer and play (or work, right?)!
3. NinjaCalc should automatically inform you if there is a new version available on start-up of the application.

Note: Installing a newer version of NinjaCalc should automatically overwrite the old one.


# Developing


1. Download/clone this repository into a folder on your computer.
2. Make sure you have a 32-bit version of the JDK installed (must be at least JDK 8).
3. Open the project in IntelliJ (`.idea/workspace.xml` file included in repo).
4. In IntelliJ, open the project settings, and point the projects JDK to installed version on your computer.
5. Develop!

[Scene Builder](http://gluonhq.com/labs/scene-builder/) can be great tool to install alongside IntelliJ for faster development of the JavaFX UI.


# Making Your Own Calculators

There are many pre-built calculator view objects to make development faster and keep a consistent look and feel across the application. These are located in `src/Core/View`. This includes:

1. A Dimension object


# Creating A Calculator Diagram

Creating a static diagram image and laying the calculator variable UI elements overtop of this is the easiest method to create a diagram when dynamic visual changes to the diagram are not required.

All calculators that use static images for their background diagrams have a Visio file called `diagram.vsd` in their respective folder. Microsoft Visio is used to create the diagram, which is then exported as an image and used inside the NinjaCalc application.


# Release Process

The team at [ej-technologies](https://www.ej-technologies.com/) have graciously donated me an open-source licensed version of ![install4j](https://www.ej-technologies.com/images/product_banners/install4j_small.png), [the multi-platform installer builder for Java applications](http://www.ej-technologies.com/products/install4j/overview.html).

Myself (gbmhunter) currently holds the license for this software, and so I am the only one that can currently create installable packages for NinjaCalc releases.

The install4j script is located at `/NinjaCalc.install4j`.

1. After code changes are complete, make sure the NinjaCalc.jar artifact has been built from within IntelliJ (`Build->Build Artifacts->NinjaCalc:jar->Build`).
2. Open the `/NinjaCalc.install4j` file in "install4j Multi-Platform Edition".
3. Update the "Version" field as appropriate, then click "Save Project".
4. Click the "Build Project" button.
5. Wait until build completes. install4j should have created installer files for each supported platform (currently Windows and Mac OS), as well as an updates.xml file, in the `install` directory.
6. Overwrite the old `updates.xml` file in the repos root directory with the one that install4j created in the `install` directory.
7. Upload the installable packages to GitHub as a new release (if appropriate).
8. Commit and push the repository changes to the master branch (updates.xml is the most important file to be updated). The "Git Flow" plugin for SourceTree can make this step easy.
9. Update the download button links on the homepage in the `gh-pages` branch of the repo to point to the new release files.


# Debugging A Deployed App (Locally)
1. Run `npm install` to install dependencies (make sure node/npm is installed on your system).
1. Open the project in WebStorm (`.idea/workspace.xml` file included in repo), or your favourite text/code editor.
1. Develop!

You can get the `System.out` and `System.err` streams by running the `NinjaCalc.jar` file from the commandline. For example, in Windows you would type at the command-line:
# Releasing


`C:\Program Files (x86)\NinjaCalc\java -jar NinjaCalc.jar`

# File Structure


Sorted by alphabetical order.

### (root level)

Contains the install4j script for generating single-file installable packages for the various operating systems.


### install/

The install4j script in the repo's root directory will instruct install4j to place deployment-ready NinjaCalc installers for the various operating systems here.


### out/

IntelliJ IDEA will place output Java files when debugging/building in this directory.


### src/

Contains the source code. This is split into the following sub-directories:

calculators/ - Contains all of the data to create each calculator type.

Core/ - Contains all the "core", non-calculator specific classes that make up the backend calculator engine and front-end visual elements.

Img/ - Contains images which are incorporated into the app.

MainWindow/ - Contains the Java code and .fxml file describing the main window of NinjaCalc.

test/ - Unit tests for each of the calculators, core modules and utility modules. The unit tests include the testing of the UI (more on this below).

Utility/ - Contains helper Java classes which are not considered "core", but still used by multiple calculators. This includes things such as a library to help you find the closest standard E-series resistance (preferred value), and a library to convert from doubles to strings with metric prefixes and back again.


# Unit Tests

Unit tests are under the `test/` directory. This directory mimics the same directory structure of `src/`.

Tests are easily run from within IntelliJ. To run all tests, right click on the `test` folder from within IntelliJ and click *Run 'All Tests'*.

Tests involving JavaFX can be easily written by making sure the test class in question extends `ApplicationTest`. `ApplicationTest` is a class from the [TestFX library](https://github.com/TestFX/TestFX) which is used here to test the JavaFX UI for each calculator. The `ApplicationTest` class makes sure that JavaFX is initialised correctly before your tests are run. You have to provide a `start(Stage stage)` method for each test class. Here is an example:

````java
import javafx.stage.Stage;
import javafx.scene.control.TextField;
import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;

public class ExampleJavaFxTests extends ApplicationTest {

@Override
public void start(Stage stage) {
}

@Test
public void basicFirstTest() {
// You can create JavaFX object here and they will work correctly
// (no initialisation exceptions will be thrown)
TextField textField = new TextField();
}
}
````
1. Make sure you are on the `develop` branch and all changes from `feature/xxx` branches have been merged into it.
1. Update `changelog.md` with a list of changes since the last release, under a heading which is the new version number (e.g. `v1.2.0`).
1. Commit the changes made above to the `develop` branch.
1. Merge the `develop` branch into the `master` branch.
1. Tag the commit on the master branch with the version number (e.g. `v1.2.0`).
1. Push all branches to the remote GitHub repo. Heroku will automatically build and deploy the new version committed onto the `master` branch.

# Changelog

See [changelog.md](../blob/master/changelog.md).


# Contributors

See the [project home page](http://mbedded-ninja.github.io/NinjaCalc/) for a list of contributors.
See the [project home page](http://mbedded-ninja.github.io/NinjaCalc/) for a list of contributors.
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v2.1.0
------

- Added data so that NinjaCalc website appears correctly when linked to on social media, closes #136.
- Added ability to close a calculator tab, closes #139.
- Added support for function-based units for numerical calculator variables, closes #140.
- Removed value property from the Unit class, closes #141.
- Added "search" functionality to the calculator selection overlay, closes #142.

v2.0.0
------

Expand Down
11 changes: 8 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
<html>
<head>
<meta charset="utf-8">
<title>vue-webpack</title>
<title>NinjaCalc</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<!-- MathJAX for rendering equations on calculator panes -->
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<!-- Preview image when webpage is shared on Open Graph XML sites (e.g. Facebook) -->
<meta property="og:image"
content="http://mbedded-ninja.github.io/NinjaCalc/img/logo-facebook-open-graph-xml-v2-1200x630.png"/>
<meta property="og:description"
content="A embedded engineering calculator toolbox for doing calculations in a breeze."/>
</head>
<body style="height: 100%;">
<div id="app"></div>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"unit-cont": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
"postinstall": "npm run build",
"start": "node server.js"
Expand Down Expand Up @@ -69,6 +69,7 @@
"opn": "^4.0.2",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"ora": "^1.1.0",
"phantomjs-polyfill-find": "github:ptim/phantomjs-polyfill-find",
"phantomjs-prebuilt": "^2.1.14",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
Expand Down
54 changes: 38 additions & 16 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
<!--</ui-tab>-->
<!--</ui-tabs>-->

<el-tabs type="card" v-if="this.$store.state.openCalcs.length" v-model="activeTabId">
<!-- The "editable" property allows you to close tabs. Note that by default this also adds a "+" button on the far-
right of the tab header, but we disable this in CSS -->
<el-tabs type="card" v-if="this.$store.state.openCalcs.length" v-model="activeTabId" editable @edit="handleTabsEdit">
<!-- The name property is the unique ID which identifies the tab -->
<el-tab-pane v-for="item in this.$store.state.openCalcs" :label="item.name" :name="item.uniqueId.toString()">
<component :is="item.componentName"></component>
Expand All @@ -45,6 +47,8 @@

<script>
/* eslint-disable */
// import { CalculatorServiceSingleton } from './services/CalculatorService'
import Vue from 'vue'
Expand All @@ -63,11 +67,6 @@
import { viaCurrentIpc2221ACalculator } from './components/Calculators/Electronics/Pcb/ViaCurrentIpc2221A/Calc'
import { crcCalculator } from './components/Calculators/Software/Crc/Calc'
console.log('LeftSideMenu =')
console.log(LeftSideMenu)
// console.log('MainView =')
// console.log(MainView)
export default {
name: 'app',
components: {
Expand All @@ -94,6 +93,22 @@
this.$store.commit('showLeftSideBar', {
trueFalse: true
})
},
handleTabsEdit (targetName, action) {
console.log('App.handleTabEdit() called.')
switch (action) {
case 'add':
// This should never get called, since we hid the "add" button!
throw new Error('action.add() is not supported by App.handleTabsEdit().')
case 'remove':
this.$store.commit('closeCalculator', {
// Need to convert string to integer
uniqueId: parseInt(targetName)
})
break
default:
throw new Error('Provided action to handleTabsEdit() was not supported.')
}
}
},
watch: {},
Expand All @@ -102,50 +117,50 @@
// ========== ELECTRONICS -> BASIC ============ //
// ============================================ //
Vue.component(OhmsLawCalculator.mainView.name, OhmsLawCalculator.mainView)
this.$store.commit('registerCalc', OhmsLawCalculator)
this.$store.dispatch('registerCalc', OhmsLawCalculator)
Vue.component(ResistorDividerCalculator.mainView.name, ResistorDividerCalculator.mainView)
this.$store.commit('registerCalc', ResistorDividerCalculator)
this.$store.dispatch('registerCalc', ResistorDividerCalculator)
Vue.component(StandardResistanceCalculator.mainView.name, StandardResistanceCalculator.mainView)
this.$store.commit('registerCalc', StandardResistanceCalculator)
this.$store.dispatch('registerCalc', StandardResistanceCalculator)
// ============================================ //
// ========= ELECTRONICS -> FILTERS =========== //
// ============================================ //
Vue.component(LowPassRCCalculator.mainView.name, LowPassRCCalculator.mainView)
this.$store.commit('registerCalc', LowPassRCCalculator)
this.$store.dispatch('registerCalc', LowPassRCCalculator)
// ============================================ //
// ========= ELECTRONICS -> SENSORS =========== //
// ============================================ //
Vue.component(dewPointMagnusCalculator.mainView.name, dewPointMagnusCalculator.mainView)
this.$store.commit('registerCalc', dewPointMagnusCalculator)
this.$store.dispatch('registerCalc', dewPointMagnusCalculator)
Vue.component(ntcThermistorTemperature.mainView.name, ntcThermistorTemperature.mainView)
this.$store.commit('registerCalc', ntcThermistorTemperature)
this.$store.dispatch('registerCalc', ntcThermistorTemperature)
// ============================================ //
// =========== ELECTRONICS -> PCB ============= //
// ============================================ //
Vue.component(trackCurrentIpc2221ACalculator.mainView.name, trackCurrentIpc2221ACalculator.mainView)
this.$store.commit('registerCalc', trackCurrentIpc2221ACalculator)
this.$store.dispatch('registerCalc', trackCurrentIpc2221ACalculator)
Vue.component(TrackCurrentIpc2152Calculator.mainView.name, TrackCurrentIpc2152Calculator.mainView)
this.$store.commit('registerCalc', TrackCurrentIpc2152Calculator)
this.$store.dispatch('registerCalc', TrackCurrentIpc2152Calculator)
Vue.component(viaCurrentIpc2221ACalculator.mainView.name, viaCurrentIpc2221ACalculator.mainView)
this.$store.commit('registerCalc', viaCurrentIpc2221ACalculator)
this.$store.dispatch('registerCalc', viaCurrentIpc2221ACalculator)
// ============================================ //
// ================== SOFTWARE ================ //
// ============================================ //
Vue.component(crcCalculator.mainView.name, crcCalculator.mainView)
this.$store.commit('registerCalc', crcCalculator)
this.$store.dispatch('registerCalc', crcCalculator)
}
}
</script>
Expand Down Expand Up @@ -198,6 +213,13 @@
padding-right: 10px;
}
/* This hides the "+" button which is automatically added
to the far-right of the tab header when the "editable"
property is supplied to the tab component */
span.el-tabs__new-tab {
display: none;
}
div.el-tabs__content {
height: 100%;
}
Expand Down
Loading

0 comments on commit 827e18f

Please sign in to comment.