Esempio n. 1
0
def mainZMQ():
    hostname = socket.gethostname()
    local_ip = socket.gethostbyname(hostname)
    if opc == "sp":
        #0.'Site_1_of_3.csv': site1.ini
        print("MainController is generating data for all sites!!!")
        dataToCopy, remDir, shareDir = initialize.main(local_ip, port, NoSites)
    else:
        #3.Execute steps in all Sites
        ExecStepsInAll()
Esempio n. 2
0
def main():

    ini.load_gazebo_models()
    raw_input("Press Enter after placing the math equation...")

    cam = Headcam()

    cam.main()
    raw_input("Press Enter after solving the math equation...")
    path = os.path.dirname(os.path.abspath(__file__))
    f = open(os.path.join(os.path.join(path, "recnsolve"), "answer.txt"), "r")
    num = str(f.read()).rstrip()

    display_image.send_image(num)
    ini.main()
    raw_input("Press Enter after baxter reaches initial pose...")
    dr = Draw()
    dr.move(num)
    raw_input("Press Enter to exit...")
    rospy.on_shutdown(ini.delete_gazebo_models)
Esempio n. 3
0
def main():
    hostname = socket.gethostname()
    local_ip = socket.gethostbyname(hostname)
    context = zmq.Context()
    sock = context.socket(zmq.REP)
    sock.bind("tcp://*:%s" % port)

    sites = {}
    print("MainController listening all sites:", NoSites)
    time.sleep(60)

    #split data to be sended to all sites
    if opc == "sp":
        #0.'Site_1_of_3.csv': site1.ini
        print("MainController is generating data for all sites!!!")
        dataToCopy, remDir, shareDir = initialize.main(local_ip, port, NoSites)
    elif opc == "em":
        #Enable this option if maincrontroller must evaluate aggregated dataset
        print("MainController is ensembling data and models for all sites!!!")
        main_FDC.generateAllDataSets(file)
        main_FDC.ensembleModels(file)
        time.sleep(10)
    elif opc == "bc":
        while True:
            print("*******" * 20)
            print(
                "MainController is managing the construction of local model from all sites:",
                NoSites)
            j = sock.recv_json()
            step, site = j['msg'].split(",")
            sites[site] = "First"

            if step == "First":
                print("First message received from Site:", site)
                send_next_step(sock, {"Central": "Second"})
                if valSites(sites, step):
                    print("sites", sites, "step", step)
                    break
            else:
                send_next_step(sock, {})

        time.sleep(2)
        while True:
            j = sock.recv_json()
            step, site = j['msg'].split(",")
            sites[site] = "Third"
            if step == "Third":
                sock.send(b"STOP")
                if valSites(sites, step):
                    print("sites", sites, "step", step)
                    break
            else:
                send_next_step(sock, {})
    elif opc == "ac":
        print("*******" * 20)
        print(
            "MainController is managing the evaluation of collaborative model from all sites:",
            NoSites)
        while True:
            j = sock.recv_json()
            step, site = j['msg'].split(",")
            sites[site] = "Third"

            if step == "Third":
                print("Third message received from Site:", site)
                send_next_step(sock, {"Central": "Fourth"})
                if valSites(sites, step):
                    print("sites", sites, "step", step)
                    break
            else:
                send_next_step(sock, {})

        time.sleep(2)
        while True:
            j = sock.recv_json()
            step, site = j['msg'].split(",")
            sites[site] = "Fifth"
            if step == "Fifth":
                sock.send(b"STOP")
                if valSites(sites, step):
                    print("sites", sites, "step", step)
                    break
            else:
                send_next_step(sock, {})

    print("The main mainController has processed all sites:", str(NoSites))
    print("Successful process!!!")

    #Evaluate collaborative model
    if opc == "ev":
        main_FDC.evalCollabModels(file, "MC")
        print("The collaborative models have been satisfactorily evaluated.",
              str(NoSites))
        print("Successful process!!!")
Esempio n. 4
0
        #     variables = defaultdict(list)
        #     for variable, position, code in data:
        #         variables[variable].append(f'cb_{code}')
        #     for variable, codes in variables.items():
        #         #remove duplicates from codes
        #         codes = list(dict.fromkeys(codes))
        #         sql = f'update vdata set {variable}.Coding={{{",".join(codes)}}} where respondent.serial = {serial}\n'
        #         f.write(sql)

    print('OK')


def refresh_dashboard():
    print('Refreshing dashboard...', end=' ')
    mssql_cursor.execute(f'exec dbo.refresh_dashboard')
    mssql_conn.commit()
    print('OK')


def main():
    print('OUTPUTS CREATION')
    write_dau()
    write_cfile()
    refresh_dashboard()
    print('Output creation complete', end='\n\n')


if __name__ == '__main__':
    import initialize
    initialize.main()
    main()
Esempio n. 5
0
========================================
    [ntr]    : Enter Transactions
    [edt]    : Edit Transactions  
    [vts]    : View Transactions
    [eda]    : Edit Accounts
    [vwa]    : View Accounts
    [ana]    : Analyze Accounts 
    [esc]    : Exit menu
"""

# Script
# Ensure file exists
if not os.path.isfile(data_file_str):
    data_file = open(data_file_str, "w")
    data_file.close()
variables, accounts, transactions_dirty = initialize.main(data_file_str)
transactions = bc.remove_duplicates(
    transactions_dirty)  # Remove impure Transactions (duplicates)

# Menu looping
while True:
    print(menu)
    try:
        choice = input("Your choice: ").rstrip()
        if choice == "ntr":
            transactions += trans_entry.main()
            # Add data to Account objects
            accounts_t = (account_init.create_from(transactions))
            # Account for duplicate Accounts created from Transactions
            accounts = account_init.merge_accounts(accounts_t + accounts)
        elif choice == "edt":
Esempio n. 6
0
========================================
    [ntr]    : Enter Transactions
    [edt]    : Edit Transactions  
    [vts]    : View Transactions
    [eda]    : Edit Accounts
    [vwa]    : View Accounts
    [ana]    : Analyze Accounts 
    [esc]    : Exit menu
"""

# Script
# Ensure file exists
if not os.path.isfile(data_file_str): 
    data_file = open(data_file_str, "w")
    data_file.close()  
variables, accounts, transactions_dirty=initialize.main(data_file_str)
transactions = bc.remove_duplicates(transactions_dirty) # Remove impure Transactions (duplicates)

# Menu looping 
while True: 
    print(menu)
    try: 
        choice = input("Your choice: ").rstrip()
        if choice == "ntr":
            transactions += trans_entry.main()
            # Add data to Account objects
            accounts_t=(account_init.create_from(transactions))
            # Account for duplicate Accounts created from Transactions 
            accounts=account_init.merge_accounts(accounts_t + accounts)
        elif choice == "edt":
            trans_edit.main(transactions, accounts)