Skip to content

Commit

Permalink
Merge pull request #66 from JdeRobot/Enchaned-Synthesis
Browse files Browse the repository at this point in the history
Update main.py
  • Loading branch information
muhammadtahasuhail authored Dec 14, 2020
2 parents fbe996c + 9e60abf commit e2886fc
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions app/backend/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import tkinter
import numpy as np
import multiprocessing
from block import Block
from wires.wire_str import Wire_Read
from lib.block import Block
from utils.wires.wire_str import read_string

def loginfo(to_display):
text.insert(tkinter.END, to_display+'\n')
Expand Down Expand Up @@ -63,8 +63,10 @@ def monitor_frequency(memories):
loginfo("<---------- Frequency Monitor ---------->\n\n")
for memory in memories:
message = memory.get()
message = "Block Name: " + message[0] + " ---> Frequency: " + message[1]
loginfo(message)

for msg in message:
loginfo(msg)
loginfo("--------------------")

sleep(0.2)

Expand All @@ -86,6 +88,7 @@ def build():
for key in keys:

name = info[key]['package']['name']
name += info[key]['package']['version'].replace('.', '')
type_names.append((key, name))
loginfo("Creating Block: "+ name)

Expand Down Expand Up @@ -135,6 +138,7 @@ def build():

script = element['data']['code']
scr_name = info[key]['package']['name']
scr_name += info[key]['package']['version'].replace('.', '')
generate_py_script(script, scr_name)

elif element['type'] == 'basic.constant':
Expand Down Expand Up @@ -209,18 +213,15 @@ def build():
# Creating processes and assigning blocks.
loginfo("Creating Processes...")
processes = []

for i, element in enumerate(blocks):


from importlib import import_module
from importlib import import_module
for i, element in enumerate(blocks):

block_name = element.name

if element.id_type == 'basic.code':
method_name = 'modules.' + block_name + '.loop'
else:
method_name = 'modules.' + block_name + '.' + block_name

method_name = 'modules.' + block_name + '.loop'
module, function = method_name.rsplit('.',1)
mod = import_module(module)
method = getattr(mod, function)
Expand All @@ -230,16 +231,22 @@ def build():
output_args = element.output_ports
parameters = element.parameters

flags = [1,0,0]
processes.append(multiprocessing.Process(target=method,
args=(input_args, output_args, parameters,)))
args=(block_name, input_args, output_args, parameters, flags,)))

processes[i].start()

loginfo("Starting Application")

root.update_idletasks()
root.update()

memories = []
for process in processes:
memories.append(Wire_Read(str(process.pid)))
process.start()

loginfo("Starting Application")
memories = []
for process in processes:
memories.append(read_string(str(process.pid)))

while True:

Expand Down

0 comments on commit e2886fc

Please sign in to comment.