main.py

#!/usr/bin/python

# -*- coding: UTF-8 -*-

from KeepOriginal import keepOriginal

from ReadAndLoadFsfb import readConfig

from ReadAndLoadFsfb import loadConfig

if __name__ == '__main__':

readconfig = readConfig('./FSFB.INI')

sections = readconfig.getsections()

for con_name in sections:

if con_name.find('CON') == 0:

loadconfig = loadConfig(con_name)

loadconfig.addsection('FSFB2_GLOBAL')

loadconfig.setvalue('FSFB2_GLOBAL', 'main_cycle', readconfig.getvalue('FSFB2_GLOBAL', 'main_cycle'))

loadconfig.setvalue('FSFB2_GLOBAL', 'connection_num', 1)

loadconfig.setvalue('FSFB2_GLOBAL','net_task_num',1)

loadconfig.setvalue('FSFB2_GLOBAL', 'CASCO_ID', readconfig.getvalue(con_name,'CASCO_ID'))

loadconfig.setvalue('FSFB2_GLOBAL','local_CTCS_ID',readconfig.getvalue(con_name,'CTCS_ID'))

loadconfig.setvalue('FSFB2_GLOBAL','local_CTCS_ID_type',readconfig.getvalue(con_name,'CTCS_IdType'))

loadconfig.setvalue('FSFB2_GLOBAL','source_addr',readconfig.getvalue(con_name,'dest_addr'))

loadconfig.setvalue('FSFB2_GLOBAL','local_dataVer_A',readconfig.getvalue(con_name,'remote_dataVer_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_dataVer_B',readconfig.getvalue(con_name,'remote_dataVer_B'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sinit_A',readconfig.getvalue(con_name,'remote_sinit_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sinit_B',readconfig.getvalue(con_name,'remote_sinit_B'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sid_A',readconfig.getvalue(con_name,'remote_sid_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sid_B',readconfig.getvalue(con_name,'remote_sid_B'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sys_chk_A',readconfig.getvalue('FSFB2_GLOBAL','local_sys_chk_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_sys_chk_B',readconfig.getvalue('FSFB2_GLOBAL','local_sys_chk_B'))

loadconfig.setvalue('FSFB2_GLOBAL','local_crc32_poly_value_A',readconfig.getvalue('FSFB2_GLOBAL','local_crc32_poly_value_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_crc32_poly_value_B',readconfig.getvalue('FSFB2_GLOBAL','local_crc32_poly_value_B'))

loadconfig.setvalue('FSFB2_GLOBAL','local_LFSR_poly_value_A',readconfig.getvalue('FSFB2_GLOBAL','local_LFSR_poly_value_A'))

loadconfig.setvalue('FSFB2_GLOBAL','local_LFSR_poly_value_B',readconfig.getvalue('FSFB2_GLOBAL','local_LFSR_poly_value_B'))

loadconfig.setvalue('FSFB2_GLOBAL','SFM_U2L_Q_Size_per_connection',readconfig.getvalue('FSFB2_GLOBAL','SFM_U2L_Q_Size_per_connection'))

loadconfig.setvalue('FSFB2_GLOBAL','SFM_L2U_Q_Size_per_connection',readconfig.getvalue('FSFB2_GLOBAL','SFM_L2U_Q_Size_per_connection'))

loadconfig.setvalue('FSFB2_GLOBAL','CFM_U2L_Q_Size_per_connection',readconfig.getvalue('FSFB2_GLOBAL','CFM_U2L_Q_Size_per_connection'))

loadconfig.setvalue('FSFB2_GLOBAL','CFM_L2U_Q_Size_per_connection',readconfig.getvalue('FSFB2_GLOBAL','CFM_L2U_Q_Size_per_connection'))

#loadconfig.setvalue('FSFB2_GLOBAL','L2U_Q_From_CFM_Size',readconfig.getvalue('FSFB2_GLOBAL','L2U_Q_From_CFM_Size'))

#loadconfig.setvalue('FSFB2_GLOBAL','U2L_Q_To_CFM_Size',readconfig.getvalue('FSFB2_GLOBAL','U2L_Q_To_CFM_Size'))

try:

loadconfig.setvalue('FSFB2_GLOBAL','L2U_Q_From_CFM_Size',readconfig.getvalue('FSFB2_GLOBAL','L2U_Q_From_CFM_Size'))

except:

print 'L2U_Q_From_CFM_Size no existence in FSFB!'

try:

loadconfig.setvalue('FSFB2_GLOBAL','U2L_Q_To_CFM_Size',readconfig.getvalue('FSFB2_GLOBAL','U2L_Q_To_CFM_Size'))

except:

print 'U2L_Q_To_CFM_Size no existence in FSFB!'

loadconfig.addsection('CON_0')

loadconfig.setvalue('CON_0','CASCO_ID',readconfig.getvalue('FSFB2_GLOBAL','CASCO_ID'))

loadconfig.setvalue('CON_0','CTCS_ID',readconfig.getvalue('FSFB2_GLOBAL','local_CTCS_ID'))

loadconfig.setvalue('CON_0','CTCS_IdType',readconfig.getvalue('FSFB2_GLOBAL','local_CTCS_ID_type'))

loadconfig.setvalue('CON_0','FSFB_comm_cycle',0)

loadconfig.setvalue('CON_0','dest_addr',readconfig.getvalue('FSFB2_GLOBAL','source_addr'))

loadconfig.setvalue('CON_0','enable_CRSCD_pack',0)

loadconfig.setvalue('CON_0','deltaTime',5)

loadconfig.setvalue('CON_0','lifeTime',5)

loadconfig.setvalue('CON_0','torlerate_cycle',6)

loadconfig.setvalue('CON_0','num_data_ver',1)

loadconfig.setvalue('CON_0','remote_dataVer_A',readconfig.getvalue('FSFB2_GLOBAL','local_dataVer_A'))

loadconfig.setvalue('CON_0','remote_dataVer_B',readconfig.getvalue('FSFB2_GLOBAL','local_dataVer_B'))

loadconfig.setvalue('CON_0','remote_sinit_A',readconfig.getvalue('FSFB2_GLOBAL','local_sinit_A'))

loadconfig.setvalue('CON_0','remote_sinit_B',readconfig.getvalue('FSFB2_GLOBAL','local_sinit_B'))

loadconfig.setvalue('CON_0','remote_sid_A',readconfig.getvalue('FSFB2_GLOBAL','local_sid_A'))

loadconfig.setvalue('CON_0','remote_sid_B',readconfig.getvalue('FSFB2_GLOBAL','local_sid_B'))

loadconfig.setvalue('CON_0','com_type',0)

loadconfig.setvalue('CON_0','check_idle_cycle',40)

loadconfig.setvalue('CON_0','maintain_cycle',50)

loadconfig.setvalue('CON_0','packet_send_delay',5)

loadconfig.setvalue('CON_0','enable_UDP_chn_FSFB',0)

loadconfig.setvalue('CON_0','UDP_chn_apply_FSFB_ID',90)

loadconfig.setvalue('CON_0','con_L2U_Q_size',2)

loadconfig.setvalue('CON_0','UDP_channel_num',4)

loadconfig.setvalue('CON_0','local_ip_0',readconfig.getvalue(con_name,'remote_ip_0'))

loadconfig.setvalue('CON_0','local_port_0',readconfig.getvalue(con_name,'remote_port_0'))

loadconfig.setvalue('CON_0','remote_ip_0',readconfig.getvalue(con_name,'local_ip_0'))

loadconfig.setvalue('CON_0','remote_port_0',readconfig.getvalue(con_name,'local_port_0'))

try:

loadconfig.setvalue('CON_0','local_ip_1',readconfig.getvalue(con_name,'remote_ip_1'))

loadconfig.setvalue('CON_0','local_port_1',readconfig.getvalue(con_name,'remote_port_1'))

loadconfig.setvalue('CON_0','remote_ip_1',readconfig.getvalue(con_name,'local_ip_1'))

loadconfig.setvalue('CON_0','remote_port_1',readconfig.getvalue(con_name,'local_port_1'))

except:

print 'local_ip_1,local_port_1 existence!'

try:

loadconfig.setvalue('CON_0','local_ip_2',readconfig.getvalue(con_name,'remote_ip_2'))

loadconfig.setvalue('CON_0','local_port_2',readconfig.getvalue(con_name,'remote_port_2'))

loadconfig.setvalue('CON_0','remote_ip_2',readconfig.getvalue(con_name,'local_ip_2'))

loadconfig.setvalue('CON_0','remote_port_2',readconfig.getvalue(con_name,'local_port_2'))

except:

print 'local_ip_2,local_port_2 existence!'

try:

loadconfig.setvalue('CON_0','local_ip_3',readconfig.getvalue(con_name,'remote_ip_3'))

loadconfig.setvalue('CON_0','local_port_3',readconfig.getvalue(con_name,'remote_port_3'))

loadconfig.setvalue('CON_0','remote_ip_3',readconfig.getvalue(con_name,'local_ip_3'))

loadconfig.setvalue('CON_0','remote_port_3',readconfig.getvalue(con_name,'local_port_3'))

except:

print 'local_ip_1,local_port_1 existence!'

loadconfig.setvalue('CON_0','sock_send_buf_size',4096)

loadconfig.setvalue('CON_0','sock_recv_buf_size',4096)

loadconfig.setvalue('CON_0','UDP_recv_MQ_size',5)

loadconfig.setvalue('CON_0','UDP_send_MQ_size',5)

loadconfig.setvalue('CON_0','com_channel_num',1)

loadconfig.setvalue('CON_0','com_port_0',8)

loadconfig.setvalue('CON_0','Baud_rate',38400)

loadconfig.setvalue('CON_0','scom_send_MQ_size',5)

loadconfig.setvalue('CON_0','scom_recv_MQ_size',5)

loadconfig.setvalue('CON_0','scom_recv_buf_size',2048)

loadconfig.addsection('TASK_0')

loadconfig.setvalue('TASK_0','sleep_time',5)

loadconfig.setvalue('TASK_0','stack_size',50000)

loadconfig.setvalue('TASK_0','priority',80)

loadconfig.setvalue('TASK_0','pkt_send_interval',2)

loadconfig.setvalue('TASK_0','connection_num',1)

loadconfig.setvalue('TASK_0','connection_index_0',0)

loadconfig.writefile()

你可能感兴趣的:(main.py)