Primo commit frutto di extreme programming

master
Pietro Brenna 2019-07-29 18:32:13 +02:00
commit 81d90ce013
12 changed files with 12070 additions and 0 deletions

21
vue/.gitignore vendored 100644
View File

@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

29
vue/README.md 100644
View File

@ -0,0 +1,29 @@
# vue
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Run your tests
```
npm run test
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}

11606
vue/package-lock.json generated 100644

File diff suppressed because it is too large Load Diff

46
vue/package.json 100644
View File

@ -0,0 +1,46 @@
{
"name": "vue",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^2.6.5",
"vue": "^2.6.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.9.0",
"@vue/cli-plugin-eslint": "^3.9.0",
"@vue/cli-service": "^3.9.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>vue</title>
</head>
<body>
<noscript>
<strong>We're sorry but vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

28
vue/src/App.vue 100644
View File

@ -0,0 +1,28 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'app',
components: {
HelloWorld
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

252
vue/src/Segmento.js 100644
View File

@ -0,0 +1,252 @@
var macchine = [
{
id: 1,
nome: "BS 1",
n_slots: 2,
},
{
id: 2,
nome: "BS 2",
n_slots: 1,
}
]
var lavs = new Map();
lavs.set(0,
{
id: 0,
meta: false,
nome: "inizio",
classe: "root",
t_lav: 0,
t_attr: 0,
//richiede interv manuale dopo x secondi
interv_manuali: [11 * 60, 20 * 60],
t_cambio: 0,
t_deattr: 0,
});
lavs.set(1, {
id: 1,
meta: false,
macchine: [1, 2],
nome: "pippo",
cliente: "pluto",
t_lav: 15 * 60,
t_attr: 5 * 60,
t_cambio: 2 * 60,
t_deattr: 1 * 60,
});
lavs.set(2, {
id: 2,
meta: false,
macchine: [1, 2],
nome: "pippo",
cliente: "pluto",
t_lav: 15 * 60,
t_attr: 5 * 60,
t_cambio: 2 * 60,
t_deattr: 1 * 60,
});
/* I lavori allocati sono un set parzialmente ordinato: ognuno sa i predecessori. */
Set.prototype.filter = function () {
return new Set(Array.prototype.filter.apply([...this], arguments))
}
Set.prototype.every = function () {
return Array.prototype.every.apply([...this], arguments);
}
Set.prototype.some = function () {
return Array.prototype.some.apply([...this], arguments);
}
Set.prototype.map = function () {
return new Set(Array.prototype.map.apply([...this], arguments))
}
Map.prototype.filter = function () {
return new Set(Array.prototype.filter.apply([...this.entries()], arguments))
}
Map.prototype.map = function () {
return new Set(Array.prototype.map.apply([...this.entries()], arguments))
}
let tempi_non_presidiati = new Set([
{
start: 4 * 60 * 60,
end: 5 * 60 * 60
},
{
start: 9 * 60 * 60,
end: 23 * 60 * 60,
}
]);
var istanze = new Map();
function lav(istanza) {
return lavs.get(istanza.lav_id);
}
function segmenti_istanza(istanza) {
let out = [];
// prima il tempo attrezzaggio
out.push({
'tipo': 'attrezzaggio',
'manuale': true,
'dt': lav(istanza).t_attr
})
for (let i = 0; i < istanza.n_pezzi; i++) {
if (i != 0 && (lav(istanza).slots.size > 1 && lav(istanza).meta)) {
out.push({
'tipo': 'cambio_pezzo',
'manuale': true,
'dt': lav(istanza).t_cambio
});
}
let tot = lav(istanza).t_lav;
let corrente = 0;
for (let intv of lav(istanza).interv_manuali) {
out.push({
'tipo': 'lavorazione',
'manuale': false,
'dt': intv - corrente
});
out.push({
'tipo': 'intervento_manuale',
'manuale': true,
'dt': 1//secondo
})
corrente += intv;
}
out.push({
'tipo': 'lavorazione',
'manuale': false,
'dt': tot - corrente
});
}
out.push({
'tipo': 'deattrezzaggio',
'manuale': true,
'dt': lav(istanza).t_deattr
});
return out;
};
function maxs(my_istanze, macchina, slots) {
//i max sono i papabili senza successori
let con_successori = new Set();
my_istanze.forEach(ist => {
for (let pred of ist.predecessori) {
con_successori.add(pred);
}
})
return my_istanze.filter(x => x.macchina == macchina && (!slots || slots.some(y => x.slots.has(y)))).filter(x => !con_successori.has(x.id));
}
function mins(my_istanze, macchina, slots) {
let ids = my_istanze.map(x => x.id);
return my_istanze.filter(x => x.macchina == macchina && (!slots || slots.some(y => x.slots.has(y)))).filter(x => x.predecessori.every(y => !ids.has(y)));
}
function push_istanza(istanza, macchina, slots) {
if (istanza.id in istanze) {
console.error("istanza già presente");
return;
}
try {
slots = new Set([...slots]);
} catch (e) {
slots = new Set();
}
if (slots.some(x => x >= macchina.n)) {
console.error("Slot non presente");
return;
}
let the_maxs = maxs(istanze, macchina, slots);
istanza.predecessori = new Set();
istanza.slots = slots || null;
istanza.macchina = macchina;
the_maxs.forEach(x => istanza.predecessori.add(x));
istanze.set(istanza.id, istanza);
}
function setta_successori() {
for (let ist of istanze) {
ist.successori = new Set();
}
for (let [_key, ist] of istanze) {
for (let prec of ist.predecessori) {
istanze[prec].successori.add(ist.id);
}
}
}
function disponi_tutto() {
setta_successori();
let tutte_istanze = new Set(Array.from(istanze.entries()).map(x => x[1]));
for (let m of macchine) {
let id_m = m.id;
let slots = [];
for (let i = 0; i < m.n_slots; i++) {
slots.push([]);
}
let current_start = mins(tutte_istanze, id_m, null);
for (let x of current_start) {
disponi_istanza(x, slots);
}
for (let x of current_start) {
tutte_istanze.delete(x);
}
}
}
function disponi_istanza(istanza, slots) {
let my_slots = istanza.slots
if (!my_slots) {
my_slots = new Set();
for (let i = 0; i < slots.length; i++) {
my_slots.add(i);
}
}
let segms = segmenti_istanza(istanza);
for (let segm of segms) {
// prendo l'ultima roba per ogni slot
let ultimi = [];
for (let sl of slots) {
if (sl.length > 0) {
ultimi.push(sl[sl.length - 1]);
}
}
let max = Math.max(...ultimi.map(x => x.ts_end));
if (segm.manuale)
max = min_presidiato_dopo(max);
let ts_start = max;
let ts_end = segm.ts_start + segm.dt;
for (let sl of my_slots) {
slots[sl].push({ 'segm': segm, 'ts_start': ts_start, 'ts_end': ts_end });
}
}
}
function non_presidiato(ts) {
for (let non_p of tempi_non_presidiati) {
if (ts > non_p.start && ts < non_p.end)
return [true, non_p.end];
}
return [false, null];
}
function min_presidiato_dopo(ts) {
let tmp = non_presidiato(ts);
while (tmp[0]) {
ts = tmp[1];
tmp = non_presidiato(ts);
}
return ts;
}
push_istanza({
id: 0,
lav_id: 0,
n_pezzi: 0
}, 1);
push_istanza({
id: 1,
lav_id: 0,
n_pezzi: 0,
}, 2);
disponi_tutto();
push_istanza({
macchina: 1,
}, 1, 0);

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

8
vue/src/main.js 100644
View File

@ -0,0 +1,8 @@
import Vue from 'vue'
import App from './App.vue'
import './Segmento'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')