diff --git a/.codacy.yml b/.codacy.yml index 8d767ed8f6..b4fb6653cb 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -17,6 +17,5 @@ exclude_paths: - interfaces/**/* - scripts/**/* - scripts/* - - src/helics/common/cppzmq/* - tests/csharp/* diff --git a/docs/conf.py b/docs/conf.py index 37c9d85c17..4f675c8697 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,7 +59,6 @@ def ext_candidates(fpath): return None import subprocess -import os read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True' diff --git a/examples/comboFederates1/comboFed.cpp b/examples/comboFederates1/comboFed.cpp index 00b9e56d84..bbd9bbfcef 100644 --- a/examples/comboFederates1/comboFed.cpp +++ b/examples/comboFederates1/comboFed.cpp @@ -37,12 +37,12 @@ int main (int argc, char *argv[]) auto ret = app.helics_parse (argc, argv); helics::FederateInfo fi; - if (ret == helics::helicsCLI11App::parse_return::help_return) + if (ret == helics::helicsCLI11App::parse_output::help_call) { fi.loadInfoFromArgs ("--help"); return 0; } - else if (ret != helics::helicsCLI11App::parse_return::ok) + else if (ret != helics::helicsCLI11App::parse_output::ok) { return -1; } diff --git a/examples/user_guide_examples/Example_1a/Transmission/Transmission_simulator.py b/examples/user_guide_examples/Example_1a/Transmission/Transmission_simulator.py index be09c69cce..6c3bb3d315 100644 --- a/examples/user_guide_examples/Example_1a/Transmission/Transmission_simulator.py +++ b/examples/user_guide_examples/Example_1a/Transmission/Transmission_simulator.py @@ -5,20 +5,14 @@ @author: monish.mukherjee """ import scipy.io as spio -from pypower.api import case118, ppoption, runpf, runopf +from pypower.api import case118, ppoption, runpf import math import numpy -import copy import matplotlib.pyplot as plt -import matplotlib.animation as animation -from datetime import datetime, timedelta import time import helics as h import random import logging -import json -import sys -import os logger = logging.getLogger(__name__) logger.addHandler(logging.StreamHandler()) @@ -77,7 +71,7 @@ def destroy_federate(fed): #fed = create_federate() ################################# Registering federate from json ######################################## - + fed = h.helicsCreateValueFederateFromConfig('Transmission_json.json') status = h.helicsFederateRegisterInterfaces(fed, 'Transmission_json.json') federate_name = h.helicsFederateGetName(fed)[-1] @@ -85,24 +79,22 @@ def destroy_federate(fed): pubkeys_count = h.helicsFederateGetPublicationCount(fed) subkeys_count = h.helicsFederateGetInputCount(fed) print(subkeys_count) -###################### Reference to Publications and Subscription form index ############################# +###################### Reference to Publications and Subscription form index ############################# pubid = {} subid = {} for i in range(0,pubkeys_count): pubid["m{}".format(i)] = h.helicsFederateGetPublicationByIndex(fed, i) - type = h.helicsPublicationGetType(pubid["m{}".format(i)]) - print(type) + pubtype = h.helicsPublicationGetType(pubid["m{}".format(i)]) + print(pubtype) for i in range(0,subkeys_count): subid["m{}".format(i)] = h.helicsFederateGetInputByIndex(fed, i) status = h.helicsInputSetDefaultComplex(subid["m{}".format(i)], 0, 0) sub_key = h.helicsSubscriptionGetKey(subid["m{}".format(i)]) print( 'Registered Subscription ---> {}'.format(sub_key)) - -###################### Entereing Execution Mode ########################################################## + +###################### Entereing Execution Mode ########################################################## status = h.helicsFederateEnterInitializingMode(fed) status = h.helicsFederateEnterExecutingMode(fed) - - #Pypower Processing (inputs) hours = 24 @@ -111,15 +103,15 @@ def destroy_federate(fed): pf_interval = 5*60 # in seconds (minimim_resolution) acopf_interval = 15*60 # in seconds (minimim_resolution) random.seed(0) - + peak_demand = [] ppc = [] case_format = case118() peak_demand = case_format['bus'][:,2][:].copy() ppc = case_format.copy() - -###################### creating fixed load profiles for each bus based on PF interval ############################# - + +###################### creating fixed load profiles for each bus based on PF interval ############################# + # load profiles (inputs) profiles = spio.loadmat('normalized_load_data_1min_ORIGINAL.mat',squeeze_me=True,struct_as_record=False) load_profiles_1min=profiles['my_data'] @@ -127,9 +119,9 @@ def destroy_federate(fed): points = numpy.floor(numpy.linspace(0, len(load_profiles_1min)-1, resolution_load+1)) time_pf = numpy.linspace(0, total_inteval, resolution_load+1) load_profiles = load_profiles_1min[points.astype(int),:] - + ################### Creating a fixed profile for buses ################## - + bus_profiles_index=[] profile_number=0 for i in range(len(ppc['bus'])): @@ -139,65 +131,65 @@ def destroy_federate(fed): else: profile_number=profile_number+1 ################### Asserting Profiles to buses ############################ - + #bus_profiles_index = numpy.random.random_integers(0,load_profiles.shape[1]-1,len(ppc['bus'])) bus_profiles = load_profiles[:,bus_profiles_index] time_opf=numpy.linspace(0, total_inteval, numpy.floor(total_inteval/acopf_interval)+1) - -########################### Cosimulation Bus and Load Amplification Factor ######################################### - + +########################### Cosimulation Bus and Load Amplification Factor ######################################### + #Co-sim Bus (inputs) Cosim_bus_number = 118 - cosim_bus= Cosim_bus_number - 1 ## Do not chage this line + cosim_bus= Cosim_bus_number - 1 ## Do not chage this line load_amplification_factor = 15 - + #power_flow fig=plt.figure() ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) - votlage_plot=[] + voltage_plot=[] x=0 k=0 - votlage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 - -######################################### Starting Co-simulation #################################################### - + voltage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 + +######################################### Starting Co-simulation #################################################### + for t in range(0, total_inteval, pf_interval): - - ############################ Publishing Voltage to GridLAB-D ####################################################### - - voltage_gld = complex(votlage_cosim_bus*1000) + + ############################ Publishing Voltage to GridLAB-D ####################################################### + + voltage_gld = complex(voltage_cosim_bus*1000) logger.info("Voltage value = {} kV".format(abs(voltage_gld)/1000)) for i in range(0,pubkeys_count): pub = pubid["m{}".format(i)] status = h.helicsPublicationPublishComplex(pub, voltage_gld.real, voltage_gld.imag) # status = h.helicsEndpointSendEventRaw(epid, "fixed_price", 10, t) - + while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) time.sleep(0.1) - - ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## - + + ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## + for i in range(0,subkeys_count): - sub = subid["m{}".format(i)] + sub = subid["m{}".format(i)] rload, iload = h.helicsInputGetComplex(sub) logger.info("Python Federate grantedtime = {}".format(grantedtime)) logger.info("Load value = {} kW".format(complex(rload, iload)/1000)) - #print(votlage_plot,real_demand) - + #print(voltage_plot,real_demand) + actual_demand=peak_demand*bus_profiles[x,:] ppc['bus'][:,2]=actual_demand ppc['bus'][:,3]=actual_demand*math.tan(math.acos(.85)) ppc['bus'][cosim_bus,2]=rload*load_amplification_factor/1000000 ppc['bus'][cosim_bus,3]=iload*load_amplification_factor/1000000 ppopt = ppoption(PF_ALG=1) - + print('PF TIme is {} and ACOPF time is {}'.format(time_pf[x], time_opf[k])) - - ############################ Running OPF For optimal power flow intervals ############################## - - if (time_pf[x] == time_opf[k]): + + ############################ Running OPF For optimal power flow intervals ############################## + + if (time_pf[x] == time_opf[k]): results_opf = runopf(ppc, ppopt) if (results_opf['success']): ppc['bus'] = results_opf['bus'] @@ -208,9 +200,9 @@ def destroy_federate(fed): LMP_solved = numpy.vstack((LMP_solved,results_opf['bus'][:,13])) opf_time = time_opf[0:k+1]/3600 k=k+1 - - ################################ Running PF For optimal power flow intervals ############################## - + + ################################ Running PF For optimal power flow intervals ############################## + solved_pf = runpf(ppc, ppopt) results_pf = solved_pf[0] ppc['bus'] = results_pf['bus'] @@ -220,35 +212,35 @@ def destroy_federate(fed): if (x == 0): voltages = results_pf['bus'][:,7] real_demand = results_pf['bus'][:,2] - distribuiton_load = [rload/1000000] + distribution_load = [rload/1000000] else: voltages = numpy.vstack((voltages,results_pf['bus'][:,7])) real_demand = numpy.vstack((real_demand,results_pf['bus'][:,2])) - distribuiton_load.append(rload/1000000) + distribution_load.append(rload/1000000) pf_time = time_pf[0:x+1]/3600 - - votlage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] - votlage_plot.append(votlage_cosim_bus) - - ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## - + + voltage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] + voltage_plot.append(voltage_cosim_bus) + + ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## + if (x > 0) : ax1.clear() - ax1.plot(pf_time,votlage_plot,'r--') + ax1.plot(pf_time,voltage_plot,'r--') ax1.set_xlim([0,25]) ax1.set_ylabel('Voltage [in kV]') ax1.set_xlabel('Time [in hours]') ax2.clear() ax2.plot(pf_time,real_demand[:,cosim_bus],'k') - ax2.set_xlim([0, 25]) + ax2.set_xlim([0, 25]) ax2.set_ylabel('Load from distribution [in MW]') ax2.set_xlabel('Time [in hours]') plt.show(block=False) plt.pause(0.1) x=x+1 - + ########################## Creating headers and Printing results to CSVs ##################################### - + head = str('Time(in Hours)') for i in range(voltages.shape[1]): head = head+','+('Bus'+str(i+1)) @@ -264,6 +256,3 @@ def destroy_federate(fed): logger.info("Destroying federate") destroy_federate(fed) logger.info("Done!") - - - \ No newline at end of file diff --git a/examples/user_guide_examples/Example_1b/EV_Controller/EV_Controller.py b/examples/user_guide_examples/Example_1b/EV_Controller/EV_Controller.py index 5274bee839..997618badd 100644 --- a/examples/user_guide_examples/Example_1b/EV_Controller/EV_Controller.py +++ b/examples/user_guide_examples/Example_1b/EV_Controller/EV_Controller.py @@ -4,9 +4,7 @@ @author: monish.mukherjee """ -from pypower.api import case118, ppoption, runpf, runopf import matplotlib.pyplot as plt -import matplotlib.animation as animation import time import helics as h import logging @@ -19,7 +17,7 @@ def destroy_federate(fed): - status = h.helicsFederateFinalize(fed) + h.helicsFederateFinalize(fed) h.helicsFederateFree(fed) h.helicsCloseLibrary() @@ -28,7 +26,7 @@ def destroy_federate(fed): ################################# Registering federate from json ######################################## - + fed = h.helicsCreateCombinationFederateFromConfig('Control.json') federate_name = h.helicsFederateGetName(fed) print(federate_name) @@ -36,7 +34,7 @@ def destroy_federate(fed): subkeys_count = h.helicsFederateGetInputCount(fed) print(subkeys_count) print(endpoint_count) -###################### Reference to Publications and Subscription form index ############################# +###################### Reference to Publications and Subscription form index ############################# endid = {} subid = {} for i in range(0,endpoint_count): @@ -44,22 +42,21 @@ def destroy_federate(fed): end_name = h.helicsEndpointGetName(endid["m{}".format(i)]) logger.info( 'Registered Endpoint ---> {}'.format(end_name)) - for i in range(0,subkeys_count): subid["m{}".format(i)] = h.helicsFederateGetInputByIndex(fed, i) status = h.helicsInputSetDefaultComplex(subid["m{}".format(i)], 0, 0) sub_key = h.helicsSubscriptionGetKey(subid["m{}".format(i)]) logger.info( 'Registered Subscription ---> {}'.format(sub_key)) - + print( '###############################################################################################') print( '######################## Entering Execution Mode ##########################################') -###################### Entering Execution Mode ########################################################## +###################### Entering Execution Mode ########################################################## h.helicsFederateEnterExecutingMode(fed) hours = 24 total_inteval = int(60 * 60 * hours) grantedtime = -1 - update_interval = 5*60 + update_interval = 5*60 feeder_limit_upper = 4 * (1000*1000) feeder_limit_lower = 2.7 * (1000*1000) k = 0 @@ -70,12 +67,12 @@ def destroy_federate(fed): while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) time.sleep(0.1) - + time_sim.append(t/3600) - ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## - key =[]; Real_demand = []; Imag_demand = []; + ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## + key =[]; Real_demand = []; Imag_demand = []; for i in range(0,subkeys_count): - sub = subid["m{}".format(i)] + sub = subid["m{}".format(i)] rload, iload = h.helicsInputGetComplex(sub) sub_key = h.helicsSubscriptionGetKey(sub) print(sub_key) @@ -86,26 +83,25 @@ def destroy_federate(fed): Imag_feeder_load = iload feeder_real_power.append(rload/1000) feeder_imag_power.append(iload/1000) - else: + else: try: data[sub_key].append(rload/1000) except KeyError: data[sub_key] = [rload/1000] - + key.append(sub_key) Real_demand.append(rload) Imag_demand.append(iload) - + logger.info("EV Controller grantedtime = {}".format(grantedtime)) - - + logger.info('Total Feeder Load is {} + {} j'.format(Real_feeder_load, Imag_feeder_load)) - + if (Real_feeder_load > feeder_limit_upper): logger.info('Total Feeder Load is over the Feeder Upper Limit') logger.info('Warning ----> Feeder OverLimit ---> Turn off EV') - - if (k < endpoint_count): + + if (k < endpoint_count): end = endid["m{}".format(k)] logger.info('endid: {}'.format(endid)) end_name = str(h.helicsEndpointGetName(end)) @@ -118,7 +114,7 @@ def destroy_federate(fed): k=k+1 else: logger.info('All EVs are Turned off') - + if (Real_feeder_load < feeder_limit_lower): logger.info('Total Feeder Load is under the Feeder Lower Limit') logger.info('Feeder Can Support EVs ------> Turn on EV') @@ -132,7 +128,7 @@ def destroy_federate(fed): logger.info('Turning on {}'.format(end_name)) else: logger.info('All EVs are Turned on') - + fig = plt.figure() fig.subplots_adjust(hspace=0.4, wspace=0.4) i = 1 @@ -143,12 +139,12 @@ def destroy_federate(fed): ax.set_xlabel('Time ') ax.set_title(keys) i=i+1 - - plt.show(block=True) + + plt.show(block=True) data['time'] = time_sim data['feeder_load(real)'] = feeder_real_power pd.DataFrame.from_dict(data=data).to_csv('EV_Outputs.csv', header=True) - + t = 60 * 60 * 24 while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) diff --git a/examples/user_guide_examples/Example_1b/Transmission/Transmission_simulator.py b/examples/user_guide_examples/Example_1b/Transmission/Transmission_simulator.py index 7703320a11..cf77fe4432 100644 --- a/examples/user_guide_examples/Example_1b/Transmission/Transmission_simulator.py +++ b/examples/user_guide_examples/Example_1b/Transmission/Transmission_simulator.py @@ -8,17 +8,11 @@ from pypower.api import case118, ppoption, runpf, runopf import math import numpy -import copy import matplotlib.pyplot as plt -import matplotlib.animation as animation -from datetime import datetime, timedelta import time import helics as h import random import logging -import json -import sys -import os logger = logging.getLogger(__name__) logger.addHandler(logging.StreamHandler()) @@ -77,7 +71,7 @@ def destroy_federate(fed): #fed = create_federate() ################################# Registering federate from json ######################################## - + fed = h.helicsCreateValueFederateFromConfig('Transmission_json.json') status = h.helicsFederateRegisterInterfaces(fed, 'Transmission_json.json') federate_name = h.helicsFederateGetName(fed)[-1] @@ -85,24 +79,22 @@ def destroy_federate(fed): pubkeys_count = h.helicsFederateGetPublicationCount(fed) subkeys_count = h.helicsFederateGetInputCount(fed) print(subkeys_count) -###################### Reference to Publications and Subscription form index ############################# +###################### Reference to Publications and Subscription form index ############################# pubid = {} subid = {} for i in range(0,pubkeys_count): pubid["m{}".format(i)] = h.helicsFederateGetPublicationByIndex(fed, i) - type = h.helicsPublicationGetType(pubid["m{}".format(i)]) - print(type) + pubtype = h.helicsPublicationGetType(pubid["m{}".format(i)]) + print(pubtype) for i in range(0,subkeys_count): subid["m{}".format(i)] = h.helicsFederateGetInputByIndex(fed, i) status = h.helicsInputSetDefaultComplex(subid["m{}".format(i)], 0, 0) sub_key = h.helicsSubscriptionGetKey(subid["m{}".format(i)]) print( 'Registered Subscription ---> {}'.format(sub_key)) - -###################### Entereing Execution Mode ########################################################## + +###################### Entereing Execution Mode ########################################################## status = h.helicsFederateEnterInitializingMode(fed) status = h.helicsFederateEnterExecutingMode(fed) - - #Pypower Processing (inputs) hours = 24 @@ -111,15 +103,15 @@ def destroy_federate(fed): pf_interval = 5*60 # in seconds (minimim_resolution) acopf_interval = 15*60 # in seconds (minimim_resolution) random.seed(0) - + peak_demand = [] ppc = [] case_format = case118() peak_demand = case_format['bus'][:,2][:].copy() ppc = case_format.copy() - -###################### creating fixed load profiles for each bus based on PF interval ############################# - + +###################### creating fixed load profiles for each bus based on PF interval ############################# + # load profiles (inputs) profiles = spio.loadmat('normalized_load_data_1min_ORIGINAL.mat',squeeze_me=True,struct_as_record=False) load_profiles_1min=profiles['my_data'] @@ -127,9 +119,9 @@ def destroy_federate(fed): points = numpy.floor(numpy.linspace(0, len(load_profiles_1min)-1, resolution_load+1)) time_pf = numpy.linspace(0, total_inteval, resolution_load+1) load_profiles = load_profiles_1min[points.astype(int),:] - + ################### Creating a fixed profile for buses ################## - + bus_profiles_index=[] profile_number=0 for i in range(len(ppc['bus'])): @@ -139,65 +131,64 @@ def destroy_federate(fed): else: profile_number=profile_number+1 ################### Asserting Profiles to buses ############################ - + #bus_profiles_index = numpy.random.random_integers(0,load_profiles.shape[1]-1,len(ppc['bus'])) bus_profiles = load_profiles[:,bus_profiles_index] time_opf=numpy.linspace(0, total_inteval, numpy.floor(total_inteval/acopf_interval)+1) - -########################### Cosimulation Bus and Load Amplification Factor ######################################### - + +########################### Cosimulation Bus and Load Amplification Factor ######################################### + #Co-sim Bus (inputs) Cosim_bus_number = 118 - cosim_bus= Cosim_bus_number - 1 ## Do not chage this line + cosim_bus= Cosim_bus_number - 1 ## Do not chage this line load_amplification_factor = 15 - + #power_flow fig=plt.figure() ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) - votlage_plot=[] + voltage_plot=[] x=0 k=0 - votlage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 - -######################################### Starting Co-simulation #################################################### - + voltage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 + +######################################### Starting Co-simulation #################################################### + for t in range(0, total_inteval, pf_interval): - - ############################ Publishing Voltage to GridLAB-D ####################################################### - - voltage_gld = complex(votlage_cosim_bus*1000) + ############################ Publishing Voltage to GridLAB-D ####################################################### + + voltage_gld = complex(voltage_cosim_bus*1000) logger.info("Voltage value = {} kV".format(abs(voltage_gld)/1000)) for i in range(0,pubkeys_count): pub = pubid["m{}".format(i)] status = h.helicsPublicationPublishComplex(pub, voltage_gld.real, voltage_gld.imag) # status = h.helicsEndpointSendEventRaw(epid, "fixed_price", 10, t) - + while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) time.sleep(0.1) - - ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## - + + ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## + for i in range(0,subkeys_count): - sub = subid["m{}".format(i)] + sub = subid["m{}".format(i)] rload, iload = h.helicsInputGetComplex(sub) logger.info("Python Federate grantedtime = {}".format(grantedtime)) logger.info("Load value = {} kW".format(complex(rload, iload)/1000)) - #print(votlage_plot,real_demand) - + #print(voltage_plot,real_demand) + actual_demand=peak_demand*bus_profiles[x,:] ppc['bus'][:,2]=actual_demand ppc['bus'][:,3]=actual_demand*math.tan(math.acos(.85)) ppc['bus'][cosim_bus,2]=rload*load_amplification_factor/1000000 ppc['bus'][cosim_bus,3]=iload*load_amplification_factor/1000000 ppopt = ppoption(PF_ALG=1) - + print('PF TIme is {} and ACOPF time is {}'.format(time_pf[x], time_opf[k])) - - ############################ Running OPF For optimal power flow intervals ############################## - - if (time_pf[x] == time_opf[k]): + + ############################ Running OPF For optimal power flow intervals ############################## + + if (time_pf[x] == time_opf[k]): results_opf = runopf(ppc, ppopt) if (results_opf['success']): ppc['bus'] = results_opf['bus'] @@ -208,9 +199,9 @@ def destroy_federate(fed): LMP_solved = numpy.vstack((LMP_solved,results_opf['bus'][:,13])) opf_time = time_opf[0:k+1]/3600 k=k+1 - - ################################ Running PF For optimal power flow intervals ############################## - + + ################################ Running PF For optimal power flow intervals ############################## + solved_pf = runpf(ppc, ppopt) results_pf = solved_pf[0] ppc['bus'] = results_pf['bus'] @@ -220,35 +211,35 @@ def destroy_federate(fed): if (x == 0): voltages = results_pf['bus'][:,7] real_demand = results_pf['bus'][:,2] - distribuiton_load = [rload/1000000] + distribution_load = [rload/1000000] else: voltages = numpy.vstack((voltages,results_pf['bus'][:,7])) real_demand = numpy.vstack((real_demand,results_pf['bus'][:,2])) - distribuiton_load.append(rload/1000000) + distribution_load.append(rload/1000000) pf_time = time_pf[0:x+1]/3600 - - votlage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] - votlage_plot.append(votlage_cosim_bus) - - ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## - + + voltage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] + voltage_plot.append(voltage_cosim_bus) + + ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## + if (x > 0) : ax1.clear() - ax1.plot(pf_time,votlage_plot,'r--') + ax1.plot(pf_time,voltage_plot,'r--') ax1.set_xlim([0,25]) ax1.set_ylabel('Voltage [in kV]') ax1.set_xlabel('Time [in hours]') ax2.clear() ax2.plot(pf_time,real_demand[:,cosim_bus],'k') - ax2.set_xlim([0, 25]) + ax2.set_xlim([0, 25]) ax2.set_ylabel('Load from distribution [in MW]') ax2.set_xlabel('Time [in hours]') plt.show(block=False) plt.pause(0.1) x=x+1 - + ########################## Creating headers and Printing results to CSVs ##################################### - + head = str('Time(in Hours)') for i in range(voltages.shape[1]): head = head+','+('Bus'+str(i+1)) @@ -264,6 +255,4 @@ def destroy_federate(fed): logger.info("Destroying federate") destroy_federate(fed) logger.info("Done!") - - - + diff --git a/examples/user_guide_examples/Example_1c/EV_Controller/EV_Controller.py b/examples/user_guide_examples/Example_1c/EV_Controller/EV_Controller.py index 94628058fa..55bad99410 100644 --- a/examples/user_guide_examples/Example_1c/EV_Controller/EV_Controller.py +++ b/examples/user_guide_examples/Example_1c/EV_Controller/EV_Controller.py @@ -4,9 +4,7 @@ @author: monish.mukherjee """ -from pypower.api import case118, ppoption, runpf, runopf import matplotlib.pyplot as plt -import matplotlib.animation as animation import time import helics as h import logging @@ -27,7 +25,7 @@ def create_broker(): return broker def destroy_federate(fed): - status = h.helicsFederateFinalize(fed) + h.helicsFederateFinalize(fed) h.helicsFederateFree(fed) h.helicsCloseLibrary() @@ -36,7 +34,6 @@ def destroy_federate(fed): ################################# Registering federate from json ######################################## - fed = h.helicsCreateCombinationFederateFromConfig('Control.json') federate_name = h.helicsFederateGetName(fed) print(federate_name) @@ -44,7 +41,7 @@ def destroy_federate(fed): subkeys_count = h.helicsFederateGetInputCount(fed) print(subkeys_count) print(endpoint_count) -###################### Reference to Publications and Subscription form index ############################# +###################### Reference to Publications and Subscription form index ############################# endid = {} subid = {} for i in range(0,endpoint_count): @@ -57,32 +54,32 @@ def destroy_federate(fed): status = h.helicsInputSetDefaultComplex(subid["m{}".format(i)], 0, 0) sub_key = h.helicsSubscriptionGetKey(subid["m{}".format(i)]) print( 'Registered Subscription ---> {}'.format(sub_key)) - + print( '###############################################################################################') print( '######################## Entering Execution Mode ##########################################') -###################### Entering Execution Mode ########################################################## +###################### Entering Execution Mode ########################################################## h.helicsFederateEnterExecutingMode(fed) hours = 24 total_inteval = int(60 * 60 * hours) grantedtime = -1 - update_interval = 5*60 + update_interval = 5*60 feeder_limit_upper = 4 * (1000*1000) feeder_limit_lower = 2.7 * (1000*1000) k = 0 data ={}; time_sim = []; feeder_real_power = []; feeder_imag_power = [] for t in range(0, total_inteval, update_interval): - + while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) time.sleep(0.1) - + time_sim.append(t/3600) - ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## - key =[]; Real_demand = []; Imag_demand = []; + ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## + key =[]; Real_demand = []; Imag_demand = []; for i in range(0,subkeys_count): - sub = subid["m{}".format(i)] + sub = subid["m{}".format(i)] rload, iload = h.helicsInputGetComplex(sub) sub_key = h.helicsSubscriptionGetKey(sub) print(sub_key) @@ -93,26 +90,25 @@ def destroy_federate(fed): Imag_feeder_load = iload feeder_real_power.append(rload/1000) feeder_imag_power.append(iload/1000) - else: + else: try: data[sub_key].append(rload/1000) except KeyError: data[sub_key] = [rload/1000] - + key.append(sub_key) Real_demand.append(rload) Imag_demand.append(iload) - + logger.info("EV Controller grantedtime = {}".format(grantedtime)) - - + logger.info('Total Feeder Load is {} + {} j'.format(Real_feeder_load, Imag_feeder_load)) - + if (Real_feeder_load > feeder_limit_upper): logger.info('Total Feeder Load is over the Feeder Upper Limit') logger.info('Warning ----> Feeder OverLimit ---> Turn off EV') - - if (k < endpoint_count): + + if (k < endpoint_count): end = endid["m{}".format(k)] end_name = str(h.helicsEndpointGetName(end)) print(end_name) @@ -123,7 +119,7 @@ def destroy_federate(fed): k=k+1 else: logger.info('All EVs are Turned off') - + if (Real_feeder_load < feeder_limit_lower): logger.info('Total Feeder Load is under the Feeder Lower Limit') logger.info('Feeder Can Support EVs ------> Turn on EV') @@ -137,7 +133,7 @@ def destroy_federate(fed): logger.info('Turning on {}'.format(end_name)) else: logger.info('All EVs are Turned on') - + fig = plt.figure() fig.subplots_adjust(hspace=0.4, wspace=0.4) i = 1 @@ -148,12 +144,12 @@ def destroy_federate(fed): ax.set_xlabel('Time ') ax.set_title(keys) i=i+1 - - plt.show(block=True) + + plt.show(block=True) data['time'] = time_sim data['feeder_load(real)'] = feeder_real_power pd.DataFrame.from_dict(data=data).to_csv('EV_Outputs.csv', header=True) - + t = 60 * 60 * 24 while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) diff --git a/examples/user_guide_examples/Example_1c/Transmission/Transmission_simulator.py b/examples/user_guide_examples/Example_1c/Transmission/Transmission_simulator.py index d2ed99139c..f5467cb9bb 100644 --- a/examples/user_guide_examples/Example_1c/Transmission/Transmission_simulator.py +++ b/examples/user_guide_examples/Example_1c/Transmission/Transmission_simulator.py @@ -8,17 +8,11 @@ from pypower.api import case118, ppoption, runpf, runopf import math import numpy -import copy import matplotlib.pyplot as plt -import matplotlib.animation as animation -from datetime import datetime, timedelta import time import helics as h import random import logging -import json -import sys -import os logger = logging.getLogger(__name__) logger.addHandler(logging.StreamHandler()) @@ -70,14 +64,13 @@ def destroy_federate(fed): h.helicsFederateFree(fed) h.helicsCloseLibrary() - if __name__ == "__main__": broker = create_broker() #fed = create_federate() ################################# Registering federate from json ######################################## - + fed = h.helicsCreateValueFederateFromConfig('Transmission_json.json') status = h.helicsFederateRegisterInterfaces(fed, 'Transmission_json.json') federate_name = h.helicsFederateGetName(fed)[-1] @@ -85,24 +78,22 @@ def destroy_federate(fed): pubkeys_count = h.helicsFederateGetPublicationCount(fed) subkeys_count = h.helicsFederateGetInputCount(fed) print(subkeys_count) -###################### Reference to Publications and Subscription form index ############################# +###################### Reference to Publications and Subscription form index ############################# pubid = {} subid = {} for i in range(0,pubkeys_count): pubid["m{}".format(i)] = h.helicsFederateGetPublicationByIndex(fed, i) - type = h.helicsPublicationGetType(pubid["m{}".format(i)]) - print(type) + pubtype = h.helicsPublicationGetType(pubid["m{}".format(i)]) + print(pubtype) for i in range(0,subkeys_count): subid["m{}".format(i)] = h.helicsFederateGetInputByIndex(fed, i) status = h.helicsInputSetDefaultComplex(subid["m{}".format(i)], 0, 0) sub_key = h.helicsSubscriptionGetKey(subid["m{}".format(i)]) print( 'Registered Subscription ---> {}'.format(sub_key)) - -###################### Entereing Execution Mode ########################################################## + +###################### Entereing Execution Mode ########################################################## status = h.helicsFederateEnterInitializingMode(fed) status = h.helicsFederateEnterExecutingMode(fed) - - #Pypower Processing (inputs) hours = 24 @@ -111,15 +102,15 @@ def destroy_federate(fed): pf_interval = 5*60 # in seconds (minimim_resolution) acopf_interval = 15*60 # in seconds (minimim_resolution) random.seed(0) - + peak_demand = [] ppc = [] case_format = case118() peak_demand = case_format['bus'][:,2][:].copy() ppc = case_format.copy() - -###################### creating fixed load profiles for each bus based on PF interval ############################# - + +###################### creating fixed load profiles for each bus based on PF interval ############################# + # load profiles (inputs) profiles = spio.loadmat('normalized_load_data_1min_ORIGINAL.mat',squeeze_me=True,struct_as_record=False) load_profiles_1min=profiles['my_data'] @@ -127,9 +118,9 @@ def destroy_federate(fed): points = numpy.floor(numpy.linspace(0, len(load_profiles_1min)-1, resolution_load+1)) time_pf = numpy.linspace(0, total_inteval, resolution_load+1) load_profiles = load_profiles_1min[points.astype(int),:] - + ################### Creating a fixed profile for buses ################## - + bus_profiles_index=[] profile_number=0 for i in range(len(ppc['bus'])): @@ -139,65 +130,63 @@ def destroy_federate(fed): else: profile_number=profile_number+1 ################### Asserting Profiles to buses ############################ - + #bus_profiles_index = numpy.random.random_integers(0,load_profiles.shape[1]-1,len(ppc['bus'])) bus_profiles = load_profiles[:,bus_profiles_index] time_opf=numpy.linspace(0, total_inteval, numpy.floor(total_inteval/acopf_interval)+1) - -########################### Cosimulation Bus and Load Amplification Factor ######################################### - + +########################### Cosimulation Bus and Load Amplification Factor ######################################### + #Co-sim Bus (inputs) Cosim_bus_number = 118 - cosim_bus= Cosim_bus_number - 1 ## Do not chage this line + cosim_bus= Cosim_bus_number - 1 ## Do not chage this line load_amplification_factor = 15 - + #power_flow fig=plt.figure() ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) - votlage_plot=[] + voltage_plot=[] x=0 k=0 - votlage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 - -######################################### Starting Co-simulation #################################################### - + voltage_cosim_bus = (ppc['bus'][cosim_bus,7]*ppc['bus'][cosim_bus,9])*1.043 + +######################################### Starting Co-simulation #################################################### + for t in range(0, total_inteval, pf_interval): - - ############################ Publishing Voltage to GridLAB-D ####################################################### - - voltage_gld = complex(votlage_cosim_bus*1000) + ############################ Publishing Voltage to GridLAB-D ####################################################### + voltage_gld = complex(voltage_cosim_bus*1000) logger.info("Voltage value = {} kV".format(abs(voltage_gld)/1000)) for i in range(0,pubkeys_count): pub = pubid["m{}".format(i)] status = h.helicsPublicationPublishComplex(pub, voltage_gld.real, voltage_gld.imag) # status = h.helicsEndpointSendEventRaw(epid, "fixed_price", 10, t) - + while grantedtime < t: grantedtime = h.helicsFederateRequestTime (fed, t) time.sleep(0.1) - - ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## - + + ############################# Subscribing to Feeder Load from to GridLAB-D ############################################## + for i in range(0,subkeys_count): - sub = subid["m{}".format(i)] + sub = subid["m{}".format(i)] rload, iload = h.helicsInputGetComplex(sub) logger.info("Python Federate grantedtime = {}".format(grantedtime)) logger.info("Load value = {} kW".format(complex(rload, iload)/1000)) - #print(votlage_plot,real_demand) - + #print(voltage_plot,real_demand) + actual_demand=peak_demand*bus_profiles[x,:] ppc['bus'][:,2]=actual_demand ppc['bus'][:,3]=actual_demand*math.tan(math.acos(.85)) ppc['bus'][cosim_bus,2]=rload*load_amplification_factor/1000000 ppc['bus'][cosim_bus,3]=iload*load_amplification_factor/1000000 ppopt = ppoption(PF_ALG=1) - + print('PF TIme is {} and ACOPF time is {}'.format(time_pf[x], time_opf[k])) - - ############################ Running OPF For optimal power flow intervals ############################## - - if (time_pf[x] == time_opf[k]): + + ############################ Running OPF For optimal power flow intervals ############################## + + if (time_pf[x] == time_opf[k]): results_opf = runopf(ppc, ppopt) if (results_opf['success']): ppc['bus'] = results_opf['bus'] @@ -208,9 +197,9 @@ def destroy_federate(fed): LMP_solved = numpy.vstack((LMP_solved,results_opf['bus'][:,13])) opf_time = time_opf[0:k+1]/3600 k=k+1 - - ################################ Running PF For optimal power flow intervals ############################## - + + ################################ Running PF For optimal power flow intervals ############################## + solved_pf = runpf(ppc, ppopt) results_pf = solved_pf[0] ppc['bus'] = results_pf['bus'] @@ -220,35 +209,35 @@ def destroy_federate(fed): if (x == 0): voltages = results_pf['bus'][:,7] real_demand = results_pf['bus'][:,2] - distribuiton_load = [rload/1000000] + distribution_load = [rload/1000000] else: voltages = numpy.vstack((voltages,results_pf['bus'][:,7])) real_demand = numpy.vstack((real_demand,results_pf['bus'][:,2])) - distribuiton_load.append(rload/1000000) + distribution_load.append(rload/1000000) pf_time = time_pf[0:x+1]/3600 - - votlage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] - votlage_plot.append(votlage_cosim_bus) - - ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## - + + voltage_cosim_bus=results_pf['bus'][cosim_bus,7]*results_pf['bus'][cosim_bus,9] + voltage_plot.append(voltage_cosim_bus) + + ######################### Plotting the Voltages and Load of the Co-SIM bus ############################################## + if (x > 0) : ax1.clear() - ax1.plot(pf_time,votlage_plot,'r--') + ax1.plot(pf_time,voltage_plot,'r--') ax1.set_xlim([0,25]) ax1.set_ylabel('Voltage [in kV]') ax1.set_xlabel('Time [in hours]') ax2.clear() ax2.plot(pf_time,real_demand[:,cosim_bus],'k') - ax2.set_xlim([0, 25]) + ax2.set_xlim([0, 25]) ax2.set_ylabel('Load from distribution [in MW]') ax2.set_xlabel('Time [in hours]') plt.show(block=False) plt.pause(0.1) x=x+1 - + ########################## Creating headers and Printing results to CSVs ##################################### - + head = str('Time(in Hours)') for i in range(voltages.shape[1]): head = head+','+('Bus'+str(i+1)) @@ -264,6 +253,3 @@ def destroy_federate(fed): logger.info("Destroying federate") destroy_federate(fed) logger.info("Done!") - - - diff --git a/src/helics/apps/BrokerApp.cpp b/src/helics/apps/BrokerApp.cpp index 5ec419cee2..e969e62bd6 100644 --- a/src/helics/apps/BrokerApp.cpp +++ b/src/helics/apps/BrokerApp.cpp @@ -20,7 +20,7 @@ BrokerApp::BrokerApp (core_type ctype, std::vector args) { auto app = generateParser (); app->setDefaultCoreType (ctype); - if (app->helics_parse (std::move (args)) == helicsCLI11App::parse_return::ok) + if (app->helics_parse (std::move (args)) == helicsCLI11App::parse_output::ok) { processArgs (app); } @@ -32,7 +32,7 @@ BrokerApp::BrokerApp (core_type ctype, int argc, char *argv[]) { auto app = generateParser (); app->setDefaultCoreType (ctype); - if (app->helics_parse (argc, argv) == helicsCLI11App::parse_return::ok) + if (app->helics_parse (argc, argv) == helicsCLI11App::parse_output::ok) { processArgs (app); } @@ -44,7 +44,7 @@ BrokerApp::BrokerApp (core_type ctype, const std::string &argString) { auto app = generateParser (); app->setDefaultCoreType (ctype); - if (app->helics_parse (argString) == helicsCLI11App::parse_return::ok) + if (app->helics_parse (argString) == helicsCLI11App::parse_output::ok) { processArgs (app); } diff --git a/src/helics/apps/Player.hpp b/src/helics/apps/Player.hpp index a7b315adfd..1484054901 100644 --- a/src/helics/apps/Player.hpp +++ b/src/helics/apps/Player.hpp @@ -51,7 +51,7 @@ class Player : public App /** construct from command line arguments in a vector @param args the command line arguments to pass in a reverse vector */ - Player (std::vector args); + explicit Player (std::vector args); /** construct from command line arguments @param argc the number of arguments @param argv the strings in the input diff --git a/src/helics/apps/Tracer.cpp b/src/helics/apps/Tracer.cpp index 6acf206934..4319146038 100644 --- a/src/helics/apps/Tracer.cpp +++ b/src/helics/apps/Tracer.cpp @@ -421,10 +421,11 @@ void Tracer::runTo (Time runToTime) Time nextPrintTime = 10.0; try { + int iteration = 0; while (true) { helics::Time T; - int iteration = 0; + if (allow_iteration) { auto ItRes = fed->requestTimeIterative (runToTime, iteration_request::iterate_if_needed); @@ -512,7 +513,7 @@ std::shared_ptr Tracer::buildArgParserApp () auto clone_group = app->add_option_group ("cloning", "Options related to endpoint cloning operations and specifications"); clone_group->add_option ("--clone", "existing endpoints to clone all packets to and from") - ->each ([this](const std::string &clone) { + ->each ([this] (const std::string &clone) { addDestEndpointClone (clone); addSourceEndpointClone (clone); }) @@ -523,7 +524,7 @@ std::shared_ptr Tracer::buildArgParserApp () ->add_option ( "--sourceclone", "existing endpoints to capture generated packets from, this argument may be specified multiple time") - ->each ([this](const std::string &clone) { addSourceEndpointClone (clone); }) + ->each ([this] (const std::string &clone) { addSourceEndpointClone (clone); }) ->delimiter (',') ->ignore_underscore () ->type_size (-1); @@ -531,7 +532,7 @@ std::shared_ptr Tracer::buildArgParserApp () clone_group ->add_option ("--destclone", "existing endpoints to capture all packets with the specified endpoint as a " "destination, this argument may be specified multiple time") - ->each ([this](const std::string &clone) { addSourceEndpointClone (clone); }) + ->each ([this] (const std::string &clone) { addSourceEndpointClone (clone); }) ->delimiter (',') ->ignore_underscore () ->type_size (-1); @@ -542,7 +543,7 @@ std::shared_ptr Tracer::buildArgParserApp () capture_group ->add_option ("--tag,--publication,--pub", "tags(publications) to record, this argument may be specified any number of times") - ->each ([this](const std::string &tag) { + ->each ([this] (const std::string &tag) { auto taglist = stringOps::splitlineQuotes (tag); for (const auto &tagname : taglist) { @@ -552,7 +553,7 @@ std::shared_ptr Tracer::buildArgParserApp () ->type_size (-1); capture_group->add_option ("--endpoints", "endpoints to capture, this argument may be specified multiple time") - ->each ([this](const std::string &ept) { + ->each ([this] (const std::string &ept) { auto eptlist = stringOps::splitlineQuotes (ept); for (const auto &eptname : eptlist) { @@ -564,7 +565,7 @@ std::shared_ptr Tracer::buildArgParserApp () capture_group ->add_option ("--capture", "capture all the publications of a particular federate capture=\"fed1;fed2\" " "supports multiple arguments or a comma separated list") - ->each ([this](const std::string &capt) { + ->each ([this] (const std::string &capt) { auto captFeds = stringOps::splitlineQuotes (capt); for (auto &captFed : captFeds) { diff --git a/src/helics/apps/helics-broker.cpp b/src/helics/apps/helics-broker.cpp index 365c0b99b2..ee49e9ae7a 100644 --- a/src/helics/apps/helics-broker.cpp +++ b/src/helics/apps/helics-broker.cpp @@ -46,7 +46,7 @@ int main (int argc, char *argv[]) }); cmdLine.allow_extras (); auto res = cmdLine.helics_parse (argc, argv); - if (res != helics::helicsCLI11App::parse_return::ok) + if (res != helics::helicsCLI11App::parse_output::ok) { switch (res) { diff --git a/src/helics/apps/helicsApp.cpp b/src/helics/apps/helicsApp.cpp index 823ed78a5e..fc73e948c1 100644 --- a/src/helics/apps/helicsApp.cpp +++ b/src/helics/apps/helicsApp.cpp @@ -50,8 +50,8 @@ App::App (const std::string &defaultAppName, int argc, char *argv[]) void App::processArgs (std::unique_ptr &app, const std::string &defaultAppName) { remArgs = app->remaining_for_passthrough (); - auto ret = app->last_return; - if (ret == helicsCLI11App::parse_return::help_return) + auto ret = app->last_output; + if (ret == helicsCLI11App::parse_output::help_call) { if (!app->quiet) { @@ -60,7 +60,7 @@ void App::processArgs (std::unique_ptr &app, const std::string & } helpMode = true; } - if (ret != helicsCLI11App::parse_return::ok) + if (ret != helicsCLI11App::parse_output::ok) { deactivated = true; return; diff --git a/src/helics/common/logger.cpp b/src/helics/common/logger.cpp index d9ee82033d..b7a54d597e 100644 --- a/src/helics/common/logger.cpp +++ b/src/helics/common/logger.cpp @@ -23,14 +23,13 @@ SPDX-License-Identifier: BSD-3-Clause namespace helics { -Logger::Logger () +Logger::Logger () : logCore (LoggerManager::getLoggerCore ()) { - logCore = LoggerManager::getLoggerCore (); - coreIndex = logCore->addFileProcessor ([this](std::string &&message) { logFunction (std::move (message)); }); + coreIndex = logCore->addFileProcessor ([this] (std::string &&message) { logFunction (std::move (message)); }); } Logger::Logger (std::shared_ptr core) : logCore (std::move (core)) { - coreIndex = logCore->addFileProcessor ([this](std::string &&message) { logFunction (std::move (message)); }); + coreIndex = logCore->addFileProcessor ([this] (std::string &&message) { logFunction (std::move (message)); }); } Logger::~Logger () { logCore->haltOperations (coreIndex); } diff --git a/src/helics/common/loggerCore.cpp b/src/helics/common/loggerCore.cpp index 3066e36cca..ffe1741858 100644 --- a/src/helics/common/loggerCore.cpp +++ b/src/helics/common/loggerCore.cpp @@ -57,7 +57,7 @@ void LoggingCore::addMessage (int index, std::string &&message) } void LoggingCore::addMessage (int index, const std::string &message) { loggingQueue.emplace (index, message); } -int LoggingCore::addFileProcessor (std::function newFunction) +int LoggingCore::addFileProcessor (std::function newFunction) { std::lock_guard fLock (functionLock); for (int ii = 0; ii < static_cast (functions.size ()); ++ii) @@ -85,7 +85,7 @@ void LoggingCore::haltOperations (int loggerIndex) } /** update a callback for a particular instance*/ -void LoggingCore::updateProcessingFunction (int index, std::function newFunction) +void LoggingCore::updateProcessingFunction (int index, std::function newFunction) { std::lock_guard fLock (functionLock); if (index < static_cast (functions.size ())) @@ -228,8 +228,8 @@ void LoggerManager::logMessage (std::string message) LoggerManager::~LoggerManager () = default; -LoggerManager::LoggerManager (const std::string &loggerName) : name (loggerName) +LoggerManager::LoggerManager (const std::string &loggerName) + : name (loggerName), loggingControl (std::make_shared ()) { - loggingControl = std::make_shared (); } } // namespace helics diff --git a/src/helics/core/ActionMessage.cpp b/src/helics/core/ActionMessage.cpp index bd7eabe380..6f970d0fb7 100644 --- a/src/helics/core/ActionMessage.cpp +++ b/src/helics/core/ActionMessage.cpp @@ -22,10 +22,8 @@ ActionMessage::ActionMessage (action_message_def::action_t startingAction) ActionMessage::ActionMessage (action_message_def::action_t startingAction, global_federate_id sourceId, global_federate_id destId) - : ActionMessage (startingAction) + : messageAction (startingAction), source_id (sourceId), dest_id (destId), name (payload) { - source_id = sourceId; - dest_id = destId; } ActionMessage::ActionMessage (ActionMessage &&act) noexcept @@ -667,7 +665,7 @@ static constexpr size_t actEnd = sizeof (actionStrings) / sizeof (actionPair); const char *actionMessageType (action_message_def::action_t action) { auto pptr = static_cast (actionStrings); - auto res = std::find_if (pptr, pptr + actEnd, [action](const auto &pt) { return (pt.first == action); }); + auto res = std::find_if (pptr, pptr + actEnd, [action] (const auto &pt) { return (pt.first == action); }); if (res != pptr + actEnd) { return res->second; @@ -689,7 +687,8 @@ static constexpr size_t errEnd = sizeof (errorStrings) / sizeof (errorPair); const char *commandErrorString (int errorcode) { auto pptr = static_cast (errorStrings); - auto res = std::find_if (pptr, pptr + errEnd, [errorcode](const auto &pt) { return (pt.first == errorcode); }); + auto res = + std::find_if (pptr, pptr + errEnd, [errorcode] (const auto &pt) { return (pt.first == errorcode); }); if (res != pptr + errEnd) { return res->second; diff --git a/src/helics/core/BrokerBase.cpp b/src/helics/core/BrokerBase.cpp index 11f5960c8a..4b2e59e4c8 100644 --- a/src/helics/core/BrokerBase.cpp +++ b/src/helics/core/BrokerBase.cpp @@ -159,7 +159,7 @@ int BrokerBase::parseArgs (int argc, char *argv[]) auto sApp = generateCLI (); app->add_subcommand (sApp); auto res = app->helics_parse (argc, argv); - if (res != helicsCLI11App::parse_return::ok) + if (res != helicsCLI11App::parse_output::ok) { return -1; } @@ -172,7 +172,7 @@ int BrokerBase::parseArgs (std::vector args) auto sApp = generateCLI (); app->add_subcommand (sApp); auto res = app->helics_parse (std::move (args)); - if (res != helicsCLI11App::parse_return::ok) + if (res != helicsCLI11App::parse_output::ok) { return -1; } @@ -185,7 +185,7 @@ int BrokerBase::parseArgs (const std::string &initializationString) auto sApp = generateCLI (); app->add_subcommand (sApp); auto res = app->helics_parse (initializationString); - if (res != helicsCLI11App::parse_return::ok) + if (res != helicsCLI11App::parse_output::ok) { return -1; } diff --git a/src/helics/core/CommonCore.cpp b/src/helics/core/CommonCore.cpp index 7ed643097c..2b8263a17f 100644 --- a/src/helics/core/CommonCore.cpp +++ b/src/helics/core/CommonCore.cpp @@ -259,7 +259,7 @@ FederateState *CommonCore::getFederate (const std::string &federateName) const FederateState *CommonCore::getHandleFederate (interface_handle handle) { - auto local_fed_id = handles.read ([handle](auto &hand) { return hand.getLocalFedID (handle); }); + auto local_fed_id = handles.read ([handle] (auto &hand) { return hand.getLocalFedID (handle); }); if (local_fed_id.isValid ()) { auto feds = federates.lock (); @@ -283,7 +283,7 @@ FederateState *CommonCore::getFederateCore (const std::string &federateName) FederateState *CommonCore::getHandleFederateCore (interface_handle handle) { - auto local_fed_id = handles.read ([handle](auto &hand) { return hand.getLocalFedID (handle); }); + auto local_fed_id = handles.read ([handle] (auto &hand) { return hand.getLocalFedID (handle); }); if (local_fed_id.isValid ()) { return loopFederates[local_fed_id.baseValue ()].fed; @@ -294,12 +294,12 @@ FederateState *CommonCore::getHandleFederateCore (interface_handle handle) const BasicHandleInfo *CommonCore::getHandleInfo (interface_handle handle) const { - return handles.read ([handle](auto &hand) { return hand.getHandleInfo (handle.baseValue ()); }); + return handles.read ([handle] (auto &hand) { return hand.getHandleInfo (handle.baseValue ()); }); } const BasicHandleInfo *CommonCore::getLocalEndpoint (const std::string &name) const { - return handles.read ([&name](auto &hand) { return hand.getEndpoint (name); }); + return handles.read ([&name] (auto &hand) { return hand.getEndpoint (name); }); } bool CommonCore::isLocal (global_federate_id global_fedid) const @@ -366,7 +366,7 @@ bool CommonCore::allInitReady () const } // all federates must be requesting init return std::all_of (loopFederates.begin (), loopFederates.end (), - [](const auto &fed) { return fed->init_transmitted.load (); }); + [] (const auto &fed) { return fed->init_transmitted.load (); }); } bool CommonCore::allDisconnected () const @@ -383,7 +383,7 @@ bool CommonCore::allDisconnected () const bool CommonCore::allFedDisconnected () const { // all federates must have hit finished state - auto pred = [](const auto &fed) { return fed.disconnected; }; + auto pred = [] (const auto &fed) { return fed.disconnected; }; return std::all_of (loopFederates.begin (), loopFederates.end (), pred); } @@ -513,7 +513,7 @@ local_federate_id CommonCore::registerFederate (const std::string &name, const C // setting up the Logger // auto ptr = fed.get(); // if we are using the Logger, log all messages coming from the federates so they can control the level*/ - fed->setLogger ([this](int /*level*/, const std::string &ident, const std::string &message) { + fed->setLogger ([this] (int /*level*/, const std::string &ident, const std::string &message) { sendToLogger (parent_broker_id, -2, ident, message); }); @@ -796,7 +796,7 @@ const BasicHandleInfo &CommonCore::createBasicHandle (global_federate_id global_ const std::string &units, uint16_t flags) { - return handles.modify ([&](auto &hand) -> const BasicHandleInfo & { + return handles.modify ([&] (auto &hand) -> const BasicHandleInfo & { auto &hndl = hand.addHandle (global_federateId, HandleType, key, type, units); hndl.local_fed_id = local_federateId; hndl.flags = flags; @@ -816,7 +816,7 @@ interface_handle CommonCore::registerInput (local_federate_id federateID, { throw (InvalidIdentifier ("federateID not valid (registerNamedInput)")); } - auto ci = handles.read ([&key](auto &hand) { return hand.getInput (key); }); + auto ci = handles.read ([&key] (auto &hand) { return hand.getInput (key); }); if (ci != nullptr) // this key is already found { throw (RegistrationFailure ("named Input already exists")); @@ -841,7 +841,7 @@ interface_handle CommonCore::registerInput (local_federate_id federateID, interface_handle CommonCore::getInput (local_federate_id federateID, const std::string &key) const { - auto ci = handles.read ([&key](auto &hand) { return hand.getInput (key); }); + auto ci = handles.read ([&key] (auto &hand) { return hand.getInput (key); }); if (ci->local_fed_id != federateID) { return {}; @@ -860,7 +860,7 @@ interface_handle CommonCore::registerPublication (local_federate_id federateID, throw (InvalidIdentifier ("federateID not valid (registerPublication)")); } LOG_INTERFACES (parent_broker_id, fed->getIdentifier (), fmt::format ("registering PUB {}", key)); - auto pub = handles.read ([&key](auto &hand) { return hand.getPublication (key); }); + auto pub = handles.read ([&key] (auto &hand) { return hand.getPublication (key); }); if (pub != nullptr) // this key is already found { throw (RegistrationFailure ("Publication key already exists")); @@ -884,7 +884,7 @@ interface_handle CommonCore::registerPublication (local_federate_id federateID, interface_handle CommonCore::getPublication (local_federate_id federateID, const std::string &key) const { - auto pub = handles.read ([&key](auto &hand) { return hand.getPublication (key); }); + auto pub = handles.read ([&key] (auto &hand) { return hand.getPublication (key); }); if (pub->local_fed_id != federateID) { return interface_handle (); @@ -980,7 +980,7 @@ void CommonCore::setHandleOption (interface_handle handle, int32_t option, bool return; } handles.modify ( - [handle, option, option_value](auto &hand) { return hand.setHandleOption (handle, option, option_value); }); + [handle, option, option_value] (auto &hand) { return hand.setHandleOption (handle, option, option_value); }); ActionMessage fcn (CMD_INTERFACE_CONFIGURE); fcn.dest_handle = handle; @@ -1017,7 +1017,7 @@ bool CommonCore::getHandleOption (interface_handle handle, int32_t option) const { case defs::options::connection_required: case defs::options::connection_optional: - return handles.read ([handle, option](auto &hand) { return hand.getHandleOption (handle, option); }); + return handles.read ([handle, option] (auto &hand) { return hand.getHandleOption (handle, option); }); default: break; } @@ -1051,7 +1051,7 @@ void CommonCore::closeHandle (interface_handle handle) cmd.setSource (handleInfo->handle); cmd.messageID = static_cast (handleInfo->handleType); addActionMessage (cmd); - handles.modify ([handle](auto &hand) { setActionFlag (*hand.getHandleInfo (handle), disconnected_flag); }); + handles.modify ([handle] (auto &hand) { setActionFlag (*hand.getHandleInfo (handle), disconnected_flag); }); } void CommonCore::removeTarget (interface_handle handle, const std::string &targetToRemove) @@ -1251,7 +1251,7 @@ CommonCore::registerEndpoint (local_federate_id federateID, const std::string &n { throw (InvalidIdentifier ("federateID not valid (registerEndpoint)")); } - auto ept = handles.read ([&name](auto &hand) { return hand.getEndpoint (name); }); + auto ept = handles.read ([&name] (auto &hand) { return hand.getEndpoint (name); }); if (ept != nullptr) { throw (RegistrationFailure ("endpoint name is already used")); @@ -1274,7 +1274,7 @@ CommonCore::registerEndpoint (local_federate_id federateID, const std::string &n interface_handle CommonCore::getEndpoint (local_federate_id federateID, const std::string &name) const { - auto ept = handles.read ([&name](auto &hand) { return hand.getEndpoint (name); }); + auto ept = handles.read ([&name] (auto &hand) { return hand.getEndpoint (name); }); if (ept->local_fed_id != federateID) { return interface_handle (); @@ -1288,7 +1288,7 @@ CommonCore::registerFilter (const std::string &filterName, const std::string &ty // check to make sure the name isn't already used if (!filterName.empty ()) { - if (handles.read ([&filterName](auto &hand) { + if (handles.read ([&filterName] (auto &hand) { auto *res = hand.getFilter (filterName); return (res != nullptr); })) @@ -1329,7 +1329,7 @@ interface_handle CommonCore::registerCloningFilter (const std::string &filterNam // check to make sure the name isn't already used if (!filterName.empty ()) { - if (handles.read ([&filterName](auto &hand) { + if (handles.read ([&filterName] (auto &hand) { auto *res = hand.getFilter (filterName); return (res != nullptr); })) @@ -1367,7 +1367,7 @@ interface_handle CommonCore::registerCloningFilter (const std::string &filterNam interface_handle CommonCore::getFilter (const std::string &name) const { - auto filt = handles.read ([&name](auto &hand) { return hand.getFilter (name); }); + auto filt = handles.read ([&name] (auto &hand) { return hand.getFilter (name); }); if ((filt != nullptr) && (filt->handleType == handle_type::filter)) { return filt->getInterfaceHandle (); @@ -1791,7 +1791,7 @@ void CommonCore::setLoggingLevel (int logLevel) void CommonCore::setLoggingCallback ( local_federate_id federateID, - std::function logFunction) + std::function logFunction) { if (federateID == local_core_id) { @@ -1941,31 +1941,29 @@ std::string CommonCore::coreQuery (const std::string &queryStr) const { if (queryStr == "federates") { - return generateStringVector (loopFederates, [](const auto &fed) { return fed->getIdentifier (); }); + return generateStringVector (loopFederates, [] (const auto &fed) { return fed->getIdentifier (); }); } if (queryStr == "publications") { - return generateStringVector_if (loopHandles, [](const auto &handle) { return handle.key; }, - [](const auto &handle) { - return (handle.handleType == handle_type::publication); - }); + return generateStringVector_if ( + loopHandles, [] (const auto &handle) { return handle.key; }, + [] (const auto &handle) { return (handle.handleType == handle_type::publication); }); } if (queryStr == "endpoints") { - return generateStringVector_if (loopHandles, [](const auto &handle) { return handle.key; }, - [](const auto &handle) { - return (handle.handleType == handle_type::endpoint); - }); + return generateStringVector_if ( + loopHandles, [] (const auto &handle) { return handle.key; }, + [] (const auto &handle) { return (handle.handleType == handle_type::endpoint); }); } if (queryStr == "dependson") { return generateStringVector (timeCoord->getDependencies (), - [](auto &dep) { return std::to_string (dep.baseValue ()); }); + [] (auto &dep) { return std::to_string (dep.baseValue ()); }); } if (queryStr == "dependents") { return generateStringVector (timeCoord->getDependents (), - [](auto &dep) { return std::to_string (dep.baseValue ()); }); + [] (auto &dep) { return std::to_string (dep.baseValue ()); }); } if (queryStr == "isinit") { @@ -2412,7 +2410,7 @@ void CommonCore::processCommand (ActionMessage &&command) case CMD_CHECK_CONNECTIONS: { auto res = checkAndProcessDisconnect (); - auto pred = [](const auto &fed) { + auto pred = [] (const auto &fed) { auto state = fed->getState (); return (HELICS_FINISHED == state) || (HELICS_ERROR == state); }; @@ -2932,7 +2930,7 @@ void CommonCore::setAsUsed (BasicHandleInfo *hand) return; } hand->used = true; - handles.modify ([&](auto &handle) { handle.getHandleInfo (hand->handle.handle)->used = true; }); + handles.modify ([&] (auto &handle) { handle.getHandleInfo (hand->handle.handle)->used = true; }); } void CommonCore::checkForNamedInterface (ActionMessage &command) { @@ -3356,7 +3354,10 @@ void CommonCore::processFilterInfo (ActionMessage &command) } else { - setActionFlag (*endhandle, has_non_cloning_dest_filter_flag); + if (endhandle != nullptr) + { + setActionFlag (*endhandle, has_non_cloning_dest_filter_flag); + } filterC->destFilter = newFilter; } } @@ -3630,7 +3631,7 @@ void CommonCore::processCoreConfigureCommands (ActionMessage &cmd) auto op = dataAirlocks[cmd.counter].try_unload (); if (op) { - auto M = stx::any_cast> ( + auto M = stx::any_cast> ( std::move (*op)); setLoggerFunction (std::move (M)); } @@ -4305,6 +4306,6 @@ const std::string &CommonCore::getInterfaceInfo (interface_handle handle) const void CommonCore::setInterfaceInfo (helics::interface_handle handle, std::string info) { - handles.modify ([&](auto &hdls) { hdls.getHandleInfo (handle.baseValue ())->interface_info = info; }); + handles.modify ([&] (auto &hdls) { hdls.getHandleInfo (handle.baseValue ())->interface_info = info; }); } } // namespace helics diff --git a/src/helics/core/helicsCLI11.hpp b/src/helics/core/helicsCLI11.hpp index 34a950c174..006aa93fb7 100644 --- a/src/helics/core/helicsCLI11.hpp +++ b/src/helics/core/helicsCLI11.hpp @@ -29,26 +29,26 @@ class helicsCLI11App : public CLI::App "silence most print output"); } - enum class parse_return : int + enum class parse_output : int { ok = 0, - help_return, - help_all_return, - version_return, - error_return, + help_call, + help_all_call, + version_call, + parse_error, }; bool quiet{false}; - parse_return last_return{parse_return::ok}; + parse_output last_output{parse_output::ok}; template - parse_return helics_parse (Args &&... args) + parse_output helics_parse (Args &&... args) { try { parse (std::forward (args)...); - last_return = parse_return::ok; + last_output = parse_output::ok; remArgs = remaining_for_passthrough (); - return parse_return::ok; + return parse_output::ok; } catch (const CLI::CallForHelp &ch) { @@ -56,8 +56,8 @@ class helicsCLI11App : public CLI::App { exit (ch); } - last_return = parse_return::help_return; - return parse_return::help_return; + last_output = parse_output::help_call; + return parse_output::help_call; } catch (const CLI::CallForAllHelp &ca) { @@ -65,8 +65,8 @@ class helicsCLI11App : public CLI::App { exit (ca); } - last_return = parse_return::help_all_return; - return parse_return::help_all_return; + last_output = parse_output::help_all_call; + return parse_output::help_all_call; } catch (const CLI::Success &) { @@ -74,14 +74,14 @@ class helicsCLI11App : public CLI::App { std::cout << helics::versionString << '\n'; } - last_return = parse_return::version_return; - return parse_return::version_return; + last_output = parse_output::version_call; + return parse_output::version_call; } catch (const CLI::Error &ce) { - exit (ce); - last_return = parse_return::error_return; - return parse_return::error_return; + CLI::App::exit (ce); + last_output = parse_output::parse_error; + return parse_output::parse_error; } } std::vector &remainArgs () { return remArgs; } diff --git a/src/helics/core/udp/UdpComms.cpp b/src/helics/core/udp/UdpComms.cpp index 3e34ddfdcd..cfbc0d0c24 100644 --- a/src/helics/core/udp/UdpComms.cpp +++ b/src/helics/core/udp/UdpComms.cpp @@ -19,9 +19,8 @@ namespace helics namespace udp { using asio::ip::udp; -UdpComms::UdpComms () : NetworkCommsInterface (interface_type::udp) +UdpComms::UdpComms () : NetworkCommsInterface (interface_type::udp), promisePort (std::promise ()) { - promisePort = std::promise (); futurePort = promisePort.get_future (); } @@ -296,8 +295,7 @@ void UdpComms::queue_tx_function () udp::endpoint rxEndpoint; if (localTargetAddress.empty () || localTargetAddress == "*" || localTargetAddress == "udp://*") { - udp::resolver::query queryLocal (udpnet (interfaceNetwork), "127.0.0.1", - std::to_string (PortNumber)); + udp::resolver::query queryLocal (udpnet (interfaceNetwork), "127.0.0.1", std::to_string (PortNumber)); auto result = resolver.resolve (queryLocal); rxEndpoint = *result; } @@ -493,7 +491,7 @@ void UdpComms::closeReceiver () { // try connecting with the receiver socket udp::resolver resolver (serv->getBaseContext ()); - udp::resolver::query queryLocal (udpnet (interfaceNetwork),"127.0.0.1", + udp::resolver::query queryLocal (udpnet (interfaceNetwork), "127.0.0.1", std::to_string (PortNumber)); rxEndpoint = *resolver.resolve (queryLocal); } @@ -504,10 +502,7 @@ void UdpComms::closeReceiver () udp::resolver::query queryLocal (udpnet (interfaceNetwork), localTargetAddress, std::to_string (PortNumber)); rxEndpoint = *resolver.resolve (queryLocal); - } - - udp::socket transmitter (serv->getBaseContext (), udp::endpoint (udpnet (interfaceNetwork), 0)); std::string cls ("close"); diff --git a/src/helics/core/zmq/ZmqComms.cpp b/src/helics/core/zmq/ZmqComms.cpp index 6565eef1d7..58f0aff5ba 100644 --- a/src/helics/core/zmq/ZmqComms.cpp +++ b/src/helics/core/zmq/ZmqComms.cpp @@ -334,10 +334,10 @@ int ZmqComms::initializeBrokerConnections (zmq::socket_t &controlSocket) } hasBroker = true; - int cnt = 0; zmq::message_t msg; if (PortNumber < 0) { + int cnt = 0; while (PortNumber < 0) { ActionMessage getPorts = generatePortRequest ((serverMode) ? 2 : 1); diff --git a/src/helics/core/zmq/ZmqCommsSS.cpp b/src/helics/core/zmq/ZmqCommsSS.cpp index 0a4365806a..1813320bd9 100644 --- a/src/helics/core/zmq/ZmqCommsSS.cpp +++ b/src/helics/core/zmq/ZmqCommsSS.cpp @@ -521,18 +521,13 @@ int ZmqCommsSS::processRxMessage (zmq::socket_t &brokerSocket, if (serverMode) { brokerSocket.recv (&msg1); - std::string str (static_cast (msg1.data ()), msg1.size ()); - brokerSocket.recv (&msg2); } else { brokerConnection.recv (&msg1); - std::string str (static_cast (msg1.data ()), msg1.size ()); - brokerConnection.recv (&msg2); } - // std::string str2 (static_cast (msg2.data ()), msg2.size ()); status = processIncomingMessage (msg2, connection_info); return status; diff --git a/src/helics/cpp98/Federate.hpp b/src/helics/cpp98/Federate.hpp index af845d66dd..89bf5fc852 100644 --- a/src/helics/cpp98/Federate.hpp +++ b/src/helics/cpp98/Federate.hpp @@ -26,7 +26,7 @@ class FederateInfo public: FederateInfo () { fi = helicsCreateFederateInfo (); } - FederateInfo (const std::string &coretype) + explicit FederateInfo (const std::string &coretype) { fi = helicsCreateFederateInfo (); helicsFederateInfoSetCoreTypeFromString (fi, coretype.c_str (), hThrowOnError ()); @@ -108,7 +108,7 @@ class Federate { public: // Default constructor - Federate () HELICS_NOTHROW: fed (NULL), exec_async_iterate (false){}; + Federate () HELICS_NOTHROW : fed (NULL), exec_async_iterate (false){}; Federate (const Federate &fedObj) : exec_async_iterate (fedObj.exec_async_iterate) { @@ -121,7 +121,7 @@ class Federate return *this; } #ifdef HELICS_HAS_RVALUE_REFS - Federate (Federate &&fedObj) HELICS_NOTHROW: exec_async_iterate (fedObj.exec_async_iterate) + Federate (Federate &&fedObj) HELICS_NOTHROW : exec_async_iterate (fedObj.exec_async_iterate) { fed = fedObj.fed; fedObj.fed = HELICS_NULL_POINTER; diff --git a/tests/helics/application_api/MessageFederateAdditionalTests.cpp b/tests/helics/application_api/MessageFederateAdditionalTests.cpp index 77bcdb7663..03d847db07 100644 --- a/tests/helics/application_api/MessageFederateAdditionalTests.cpp +++ b/tests/helics/application_api/MessageFederateAdditionalTests.cpp @@ -104,7 +104,7 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_callback, bdata::make (core_ helics::interface_handle rxend; helics::Time timeRx; - auto mend = [&](const helics::Endpoint &ept, helics::Time rtime) { + auto mend = [&] (const helics::Endpoint &ept, helics::Time rtime) { rxend = ept.getHandle (); timeRx = rtime; }; @@ -152,7 +152,7 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_callback_obj, bdata::make (c helics::interface_handle rxend; helics::Time timeRx; - auto mend = [&](const helics::Endpoint &ept, helics::Time rtime) { + auto mend = [&] (const helics::Endpoint &ept, helics::Time rtime) { rxend = ept.getHandle (); timeRx = rtime; }; @@ -198,7 +198,7 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_callback_obj2, bdata::make ( helics::interface_handle rxend; helics::Time timeRx; - auto mend = [&](const helics::Endpoint &ept, helics::Time rtime) { + auto mend = [&] (const helics::Endpoint &ept, helics::Time rtime) { rxend = ept.getHandle (); timeRx = rtime; }; @@ -246,13 +246,13 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_2fed_multisend_callback, auto &epid2 = mFed2->registerGlobalEndpoint ("ep2", "random"); std::atomic e1cnt{0}; std::atomic e2cnt{0}; - mFed1->setMessageNotificationCallback (epid, [&](const helics::Endpoint &, helics::Time) { ++e1cnt; }); - mFed2->setMessageNotificationCallback (epid2, [&](const helics::Endpoint &, helics::Time) { ++e2cnt; }); + mFed1->setMessageNotificationCallback (epid, [&] (const helics::Endpoint &, helics::Time) { ++e1cnt; }); + mFed2->setMessageNotificationCallback (epid2, [&] (const helics::Endpoint &, helics::Time) { ++e2cnt; }); // mFed1->getCorePointer()->setLoggingLevel(0, 5); mFed1->setProperty (helics_property_time_delta, 1.0); mFed2->setProperty (helics_property_time_delta, 1.0); - auto f1finish = std::async (std::launch::async, [&]() { mFed1->enterExecutingMode (); }); + auto f1finish = std::async (std::launch::async, [&] () { mFed1->enterExecutingMode (); }); mFed2->enterExecutingMode (); f1finish.wait (); @@ -268,7 +268,7 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_2fed_multisend_callback, mFed1->sendMessage (epid, "ep2", data3); mFed1->sendMessage (epid, "ep2", data4); // move the time to 1.0 - auto f1time = std::async (std::launch::async, [&]() { return mFed1->requestTime (1.0); }); + auto f1time = std::async (std::launch::async, [&] () { return mFed1->requestTime (1.0); }); auto gtime = mFed2->requestTime (1.0); BOOST_CHECK_EQUAL (gtime, 1.0); @@ -326,12 +326,12 @@ class PingPongFed std::string name; //!< the name of the federate helics::core_type coreType; std::vector> triggers; - helics::Endpoint *ep; - int index = 0; + helics::Endpoint *ep{nullptr}; + int index{0}; public: - int pings = 0; //!< the number of pings received - int pongs = 0; //!< the number of pongs received + int pings{0}; //!< the number of pings received + int pongs{0}; //!< the number of pongs received public: PingPongFed (const std::string &fname, helics::Time tDelta, helics::core_type ctype) : delta (tDelta), name (fname), coreType (ctype) @@ -454,9 +454,9 @@ BOOST_DATA_TEST_CASE (threefedPingPong, bdata::make (core_types), core_type) p3.addTrigger (3.0, "fedB/port"); p3.addTrigger (4.0, "fedA/port"); - auto t1 = std::thread ([&p1]() { p1.run (6.0); }); - auto t2 = std::thread ([&p2]() { p2.run (6.0); }); - auto t3 = std::thread ([&p3]() { p3.run (6.0); }); + auto t1 = std::thread ([&p1] () { p1.run (6.0); }); + auto t2 = std::thread ([&p2] () { p2.run (6.0); }); + auto t3 = std::thread ([&p3] () { p3.run (6.0); }); t1.join (); t2.join (); diff --git a/tests/helics/shared_library/test-message-federate.cpp b/tests/helics/shared_library/test-message-federate.cpp index 954b77668b..0a2038d7b5 100644 --- a/tests/helics/shared_library/test-message-federate.cpp +++ b/tests/helics/shared_library/test-message-federate.cpp @@ -202,7 +202,6 @@ BOOST_DATA_TEST_CASE (message_federate_send_receive_2fed_multisend, bdata::make BOOST_CHECK (mFed2State == helics_state_execution); std::string data (500, 'a'); - std::string data2 (400, 'b'); helicsEndpointSetDefaultDestination (epid, "ep2", &err); diff --git a/tests/java/ApplicationApiTest.java b/tests/java/ApplicationApiTest.java index 1e11d1214e..a78db4ebea 100644 --- a/tests/java/ApplicationApiTest.java +++ b/tests/java/ApplicationApiTest.java @@ -5,16 +5,15 @@ import com.java.helics.SWIGTYPE_p_void; import com.java.helics.helics; -import com.java.helics.helics_status; public class ApplicationApiTest { public static SWIGTYPE_p_void createValueFederate(final String fedName, final double timeDelta) { SWIGTYPE_p_void fi = helics.helicsFederateInfoCreate(); - helics_status rv = helics.helicsFederateInfoSetFederateName(fi,fedName); - rv = helics.helicsFederateInfoSetTimeDelta(fi, timeDelta); - rv = helics.helicsFederateInfoSetCoreTypeFromString(fi, "zmq"); - rv = helics.helicsFederateInfoSetCoreInitString(fi, "1"); + helics.helicsFederateInfoSetFederateName(fi,fedName); + helics.helicsFederateInfoSetTimeDelta(fi, timeDelta); + helics.helicsFederateInfoSetCoreTypeFromString(fi, "zmq"); + helics.helicsFederateInfoSetCoreInitString(fi, "1"); SWIGTYPE_p_void valFed = helics.helicsCreateValueFederate(fi); return valFed; }