Skip to content

Commit

Permalink
Merge pull request #89 from intechstudio/SUKU-dev
Browse files Browse the repository at this point in the history
Suku dev
  • Loading branch information
SukuWc authored Apr 14, 2022
2 parents 500d6a3 + 8e46939 commit 4ee77a7
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 127 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grid_editor",
"version": "1.2.20",
"version": "1.2.21",
"main": "./src/electron.js",
"repository": {
"type": "git",
Expand Down
25 changes: 19 additions & 6 deletions src/app/main/TopSubMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
import { get, writable } from 'svelte/store';
import { appSettings } from '../runtime/app-helper.store';
import { engine, unsaved_changes } from '../runtime/runtime.store';
import { writeBuffer } from '../runtime/engine.store';
import {fade} from 'svelte/transition';
Expand Down Expand Up @@ -39,6 +40,17 @@
}
// let writeBuffer_length = 0;
// writeBuffer.subscribe(s=>{
// writeBuffer_length = s.length
// })
function debugWriteBuffer(){
console.log(get(writeBuffer));
}
</script>

Expand Down Expand Up @@ -68,15 +80,16 @@

<div class="flex items-center">

<div class="mr-6 px-3 py-1 relative flex items-center justify-center rounded-md bg-select-saturate-10 ">
<span class="pr-2 text-sm text-gray-200 tracking-wider font-light">{$engine}</span>
<button
on:click={debugWriteBuffer}
class=" relative flex items-center focus:outline-none justify-center rounded my-2 border-select bg-select border-2 text-white px-2 py-0.5 mx-1 w-48 ">
<span class="pr-2 text-gray-200 tracking-wider font-light">{$engine} {($writeBuffer.length)?("["+$writeBuffer.length+"]"):''}</span>
<svg class="w-5 h-5 p-0.5 fill-current {$engine == 'ENABLED' ? 'text-green-500' : 'text-red-500'}" viewBox="0 0 465 385" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0009 128.001H382.06L343.03 167.03C338.529 171.531 336 177.635 336 184.001C336 190.366 338.529 196.471 343.03 200.972C347.531 205.473 353.636 208.001 360.001 208.001C366.366 208.001 372.471 205.473 376.972 200.972L456.972 120.972C459.201 118.743 460.969 116.097 462.175 113.185C463.381 110.273 464.002 107.152 464.002 104.001C464.002 100.849 463.381 97.7278 462.175 94.8159C460.969 91.904 459.201 89.2582 456.972 87.0296L376.972 7.02962C372.471 2.52863 366.366 -4.74256e-08 360.001 0C353.636 4.74256e-08 347.531 2.52863 343.03 7.02962C338.529 11.5306 336 17.6353 336 24.0006C336 30.366 338.529 36.4706 343.03 40.9716L382.06 80.0006H24.0009C17.6357 80.0006 11.5312 82.5292 7.03031 87.0301C2.52944 91.5309 0.000873566 97.6354 0.000873566 104.001C0.000873566 110.366 2.52944 116.47 7.03031 120.971C11.5312 125.472 17.6357 128.001 24.0009 128.001Z"/>
<path d="M440.001 256.001H81.9419L120.972 216.972C125.473 212.471 128.001 206.366 128.001 200.001C128.001 193.635 125.473 187.531 120.972 183.03C116.471 178.529 110.366 176 104.001 176C97.6355 176 91.5309 178.529 87.0299 183.03L7.02987 263.03C4.80114 265.258 3.0332 267.904 1.82701 270.816C0.620819 273.728 0 276.849 0 280.001C0 283.152 0.620819 286.273 1.82701 289.185C3.0332 292.097 4.80114 294.743 7.02987 296.972L87.0299 376.972C91.5309 381.473 97.6355 384.001 104.001 384.001C110.366 384.001 116.471 381.473 120.972 376.972C125.473 372.471 128.001 366.366 128.001 360.001C128.001 353.635 125.473 347.531 120.972 343.03L81.9419 304.001H440.001C446.366 304.001 452.471 301.472 456.971 296.971C461.472 292.47 464.001 286.366 464.001 280.001C464.001 273.635 461.472 267.531 456.971 263.03C452.471 258.529 446.366 256.001 440.001 256.001Z" />
</svg>

</div>

</button>

<button
on:click={()=>{clear()}}
disabled={$engine != 'ENABLED'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ export function select(node){
// should be probably put into user_input store's functions
const ui = get(user_input);

if(ui.event.elementnumber != +controlNumber || ui.id != moduleId){
if(ui.event.elementnumber != +controlNumber || ui.brc.dx != dx || ui.brc.dy != dy){

user_input.update((ui) =>{

ui.id = moduleId;
ui.brc.dx = +dx;
ui.brc.dy = +dy;
ui.event.elementnumber = +controlNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/app/main/modals/Welcome.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<div id="modal-copy-placeholder"></div>

<modal class=" z-40 flex absolute items-center justify-center w-full h-screen bg-primary bg-opacity-50">
<modal class=" z-40 flex absolute items-center justify-center w-full h-screen bg-secondary bg-opacity-50">

<div use:clickOutside={{useCapture:true}} on:click-outside={()=>{$appSettings.modal = ''}} id="clickbox"
class=" z-50 w-1/2 h-1/2 text-white relative flex flex-col shadow bg-primary bg-opacity-100 items-start opacity-100">
Expand Down
20 changes: 6 additions & 14 deletions src/app/main/panels/configuration/Configuration.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@
const active_config = derived([user_input], ([ui]) => {
// whenever the UI changes, reset multiselect
appMultiSelect.reset();
const rt = get(runtime);
user_input.subscribe(ui=>{
// fetch or load config now inline
appMultiSelect.reset();
let config = [];
let selectedEvent = "";
const rt = get(runtime);
const device = rt.find(device => device.dx == ui.brc.dx && device.dy == ui.brc.dy)
if (device === undefined){
Expand All @@ -104,7 +99,8 @@
}
let module_type = ui.id.split("_")[0]
let module_type = device.id.split("_")[0]
let element_type = grid.moduleElements[module_type][ui.event.elementnumber]
let pageIndex = device.pages.findIndex(x => x.pageNumber == ui.event.pagenumber);
Expand Down Expand Up @@ -150,7 +146,7 @@
}
return {
let active = {
elementtype: element_type,
config: config,
stringname: "",
Expand All @@ -167,11 +163,7 @@
options: device.pages.map((n) => n.pageNumber)
}
}
});
// if active_config changes then...
active_config.subscribe(active => {
if (active === undefined){
return;
Expand Down
33 changes: 25 additions & 8 deletions src/app/main/panels/profiles/Profiles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@
let PROFILES = [];
user_input.subscribe(val => {
if(val.id){
newProfile.type = val.id.substr(0,4);
user_input.subscribe(ui => {
const rt = get(runtime)
let device = rt.find(device => device.dx == ui.brc.dx && device.dy == ui.brc.dy)
if (device === undefined){
return;
}
newProfile.type = device.id.substr(0,4);
})
async function checkIfWritableDirectory(path){
Expand Down Expand Up @@ -121,9 +130,7 @@
})
profileListRefresh.subscribe(store => {
console.log("REFRESH")
if (PROFILE_PATH !== undefined && PROFILE_PATH !== ""){
console.log("Profilepath", PROFILE_PATH)
loadFilesFromDirectory();
}
})
Expand Down Expand Up @@ -374,6 +381,18 @@
return ok;
}
function compare( a, b ) {
if ( a.name < b.name ){
return -1;
}
if ( a.name > b.name ){
return 1;
}
return 0;
}
// use:clickOutside={{useCapture: true}}
// on:click-outside={()=>{selected = undefined; selectedIndex = undefined;}}
</script>
Expand All @@ -382,8 +401,6 @@

class="w-full h-full p-4 flex flex-col justify-start bg-primary { $engine == 'ENABLED' ? '' : 'pointer-events-none'}">



<div in:fade={{delay:0}} class="bg-secondary bg-opacity-25 rounded-lg p-4 flex flex-col justify-start items-start">

<div class="text-white pb-2">Save Profile To Local Folder</div>
Expand Down Expand Up @@ -440,7 +457,7 @@
{/if}


{#each PROFILES as profile, i}
{#each PROFILES.sort( compare ) as profile, i}
<li
on:click={()=>{selected = profile; selectedIndex = i;}}
use:addOnDoubleClick
Expand Down
2 changes: 1 addition & 1 deletion src/app/runtime/app-helper.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function init_appsettings(){
}

s.persistant[key] = value;
console.log("init", key, value);
//console.log("init", key, value);

});

Expand Down
37 changes: 17 additions & 20 deletions src/app/runtime/engine.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ export function sendHeartbeat(type){


instructions.sendEditorHeartbeat_immediate(type)
writeBuffer.writeBufferTryNext();

}

function createWriteBuffer (){

const messages = writable([]);
function createWriteBuffer (){

let _write_buffer = [];
let _write_buffer = writable([]);

let write_buffer_busy = false;

let active_elem = undefined;



function module_destroy_handler(dx, dy){

// remove all of the elements that match the destroyed module's dx dy
_write_buffer = _write_buffer.filter(g => (g.descr.brc_parameters.DX!= dx || g.descr.brc_parameters.DY != dy));
_write_buffer.update(s=>s.filter(g => (g.descr.brc_parameters.DX!= dx || g.descr.brc_parameters.DY != dy)));

// clear the active element if it matches the destroyed module's dx dy
if (active_elem !== undefined){
Expand All @@ -37,16 +37,13 @@ function createWriteBuffer (){
}

}



}

function clear(){

console.log("clear")
_write_buffer.set([])

_write_buffer = [];
active_elem = undefined;
write_buffer_busy = false;
clearInterval(_fetch_timeout);
Expand Down Expand Up @@ -74,19 +71,19 @@ function createWriteBuffer (){

function writeBufferTryNext() {

if(write_buffer_busy || get(_write_buffer).length == 0) return;

if(write_buffer_busy || _write_buffer.length == 0) return;

if (serial_write_islocked() === true){
console.log("LOCK", _write_buffer.length)
console.log("LOCK", get(_write_buffer).length)
return;
}


write_buffer_busy = true;

active_elem = _write_buffer[0];
active_elem = get(_write_buffer)[0];

if (active_elem === undefined) return;

// create and send serial, save the ID for validation
const { id } = sendDataToGrid(active_elem.descr);
Expand All @@ -105,9 +102,7 @@ function createWriteBuffer (){

}



_write_buffer.shift();
_write_buffer.update(s=>{s.shift(); return s})

if(active_elem.responseRequired === true){

Expand All @@ -118,7 +113,7 @@ function createWriteBuffer (){
} else {
active_elem = undefined;
write_buffer_busy = false;
writeBufferTryNext();
//writeBufferTryNext();
}

};
Expand Down Expand Up @@ -192,20 +187,22 @@ function createWriteBuffer (){
}

function add_first(obj){
_write_buffer.splice(0,0,obj);

_write_buffer.update(s=> [obj, ...s])
writeBufferTryNext();
}

function add_last(obj){
_write_buffer = [..._write_buffer, obj];

_write_buffer.update(s=> [...s, obj])
writeBufferTryNext();
}



return {
subscribe: _write_buffer.subscribe,
writeBufferTryNext: writeBufferTryNext,
messages: messages,
add_first: add_first,
add_last: add_last,
validate_incoming: validateIncoming,
Expand Down
Loading

0 comments on commit 4ee77a7

Please sign in to comment.