diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-23 07:53:04 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-23 07:53:04 -0400 |
commit | a453d3b91e5d947f4706c2c355948eda7a8f15d2 (patch) | |
tree | 19d34bde5d6eadfa7521ff179d3147bc875480c0 | |
parent | 923edbae71bfe8bb465f017de119e2a3f1fbd1e2 (diff) |
initial addition of Main_Rst
-rw-r--r-- | device-functions.c | 114 | ||||
-rw-r--r-- | device-functions.h | 5 | ||||
-rw-r--r-- | globals.h | 36 | ||||
-rw-r--r-- | instr-daemon.c | 2 |
4 files changed, 145 insertions, 12 deletions
diff --git a/device-functions.c b/device-functions.c index 048241a..63d1429 100644 --- a/device-functions.c +++ b/device-functions.c @@ -1,17 +1,6 @@ #include "device-functions.h" #include "globals.h" -/* START FUNCTION DESCRIPTION ******************************************** -Set_frequency <DEVFUNC.LIB> - -SYNTAX: Set_frequency(int check_possible_only,int word_override,int range_override,int channel,float set_freq) - -KEYWORDS: - -DESCRIPTION: sets the offset DAC. - -RETURN VALUE: error code (zero = OK). -END DESCRIPTION **********************************************************/ /*----------------------------------------------------------------------------------------------------------*/ int Set_frequency(int check_possible_only,int word_override,int range_override,int channel,float set_freq) @@ -38,3 +27,106 @@ int Set_frequency(int check_possible_only,int word_override,int range_override,i return OK; } + +void Main_Rst (void) +{ + int i; + + globals.extended_ampl_min_max=NO; + + // go backwards, so channel 0 overrides everything + for (i=globals.Flash.channels-1; i>=0; --i) { + + globals.ChannelState[i].route_primary=1; + globals.ChannelState[i].route_secondary=1; + globals.ChannelState[i].frequency=globals.Flash.min_freq[i]; + globals.ChannelState[i].delay=globals.Flash.min_delay[i]; + + if (globals.Flash.min_pw[i] > 0.0) { + globals.ChannelState[i].pw=globals.Flash.min_pw[i]; + } else { + globals.ChannelState[i].pw=0.0; + } + + if (globals.Flash.ampl_min_max_only[i] || (globals.Flash.min_ampl[i] > 0.0)) { + globals.ChannelState[i].amplitude = globals.Flash.min_ampl[i]; + } else { + globals.ChannelState[i].amplitude=0.0; + } + globals.ChannelState[i].offset=0.0; + + globals.ChannelState[i].zout=globals.Flash.zout_min[i]; + globals.ChannelState[i].hold_setting = hold_width; + globals.ChannelState[i].double_pulse = double_off; + globals.ChannelState[i].ab_mode = pw_normal; + globals.ChannelState[i].func_mode = pulse_mode_on; + globals.ChannelState[i].polarity = globals.Flash.invert_by_default[i]; + globals.ChannelState[i].output_state = output_off; + globals.ChannelState[i].gate_type = gate_sync; + globals.ChannelState[i].trigger_source = source_internal; + globals.ChannelState[i].amp_mode = amp_mode_normal; + globals.ChannelState[i].os_mode = os_mode_normal; + globals.ChannelState[i].gate_level = gate_low; + globals.ChannelState[i].load_type= globals.Flash.low_load_type[i]; + globals.ChannelState[i].test_delay_mode = NO; + globals.ChannelState[i].logic_level = logic_ttl; + globals.ChannelState[i].burst_count = 1 && !globals.Flash.burst_func[i]; + globals.ChannelState[i].burst_time = globals.Constraints.composite_min_burst_time[i]; + globals.ChannelState[i].rise_time = globals.Flash.min_rise_time[i]; + globals.ChannelState[i].soft_current_limit = globals.Flash.max_soft_current_limit[i]; + globals.ChannelState[i].vcc1 = 0.0; + globals.ChannelState[i].vcc2 = globals.Flash.vcc2_min[i]; + globals.ChannelState[i].vlogic = 0.0; + globals.ChannelState[i].slew = globals.Flash.min_slew[i]; + + globals.do_check_settings=NO; /* don't check for conflicting settings */ +/* FIXME + Set_Pw(0,0,0,i,globals.ChannelState[i].pw,0); + + Set_Route(i,ROUTE_PRIMARY,globals.ChannelState[i].route_primary); + Set_Route(i,ROUTE_SECONDARY,globals.ChannelState[i].route_secondary); + + Set_frequency(0,0,0,i,globals.ChannelState[i].frequency); + Set_Delay(0,0,0,i,globals.ChannelState[i].delay); + Set_Double(i,globals.ChannelState[i].double_pulse); + Set_Pwmode(i,globals.ChannelState[i].ab_mode); + Set_Func(i,globals.ChannelState[i].func_mode); + Set_Pol(i,globals.ChannelState[i].polarity); + Set_Gate_Sync(i,globals.ChannelState[i].gate_type); + Set_Gate_Level(i,globals.ChannelState[i].gate_level); + Set_EA(i,globals.ChannelState[i].amp_mode); + Set_EO(i,globals.ChannelState[i].os_mode); + if (globals.Flash.switchable_zout[i]) { + Set_zout(i,globals.ChannelState[i].zout,1); + } + + Set_Load(i,globals.ChannelState[i].load_type); + Set_Logic_Level(i,globals.ChannelState[i].logic_level); + Set_rise_time(0,0,0,i,globals.ChannelState[i].rise_time); + Set_slew(0,0,0,i,globals.ChannelState[i].slew); + Set_current_limit(0,i,globals.ChannelState[i].soft_current_limit); + + if (globals.Flash.max_burst_count[i]>1) { + Set_Burst_Count(i,globals.ChannelState[i].burst_count,globals.ChannelState[i].burst_time); + } + + Set_Trig_Source(i,globals.ChannelState[i].trigger_source); + + Set_Amplitude(0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); + Set_Offset(0,0,0,0,i,globals.ChannelState[i].offset); + Set_Output_State(i,globals.ChannelState[i].output_state); + + Set_current_limit(0,i,globals.ChannelState[i].soft_current_limit); + + Set_avrq_ampl(0,0,0,2,globals.ChannelState[i].vcc1); + Set_avrq_ampl(0,0,0,3,globals.ChannelState[i].vcc2); + Set_avrq_ampl(0,0,0,4,globals.ChannelState[i].vlogic); +*/ globals.do_check_settings=YES; /* check for conflicting settings */ + } + + +// Error_check(globals.ChannelState); /* establishes min/max values for queries, but reports no errors */ +// update_whole_main_menu=YES; +// Ctrl_PRF_Limiter(1); +// Menu_Clear_Buttons(); +} diff --git a/device-functions.h b/device-functions.h index 2702753..0688710 100644 --- a/device-functions.h +++ b/device-functions.h @@ -1,5 +1,8 @@ #ifndef DEVICE_FUNCTIONS_H_ #define DEVICE_FUNCTIONS_H_ #include "globals.h" + int Set_frequency(int check_possible_only,int word_override,int range_override,int channel,float set_freq); -#endif
\ No newline at end of file +void Main_Rst(void); + +#endif @@ -513,11 +513,47 @@ typedef struct { } FlashStruct; #pragma pack(pop) + +typedef struct { + float err_min_freq[max_channels]; /* current minimum-allowed frequency */ + float err_max_freq[max_channels]; /* current maximum-allowed frequency */ + float err_min_pw[max_channels]; /* current minimum-allowed pulse width */ + float err_max_pw[max_channels]; /* current maximum-allowed pulse width */ + float err_min_delay[max_channels]; /* current minimum-allowed delay */ + float err_max_delay[max_channels]; /* current maximum-allowed delay */ + float err_min_ampl[max_channels]; /* current minimum-allowed amplitude */ + float err_max_ampl[max_channels]; /* current maximum-allowed amplitude */ + float err_min_offset[max_channels]; /* current minimum-allowed offset */ + float err_max_offset[max_channels]; /* current maximum-allowed offset */ + int err_max_burst_count[max_channels]; /* current maximum-allowed burst current */ + float err_min_burst_time[max_channels]; /* current minimum-allowed burst spacing */ + float err_max_burst_time[max_channels]; /* current maximum-allowed burst spacing */ + float err_min_rise_time[max_channels]; /* current minimum-allowed burst spacing */ + float err_max_rise_time[max_channels]; /* current maximum-allowed burst spacing */ + float err_min_soft_current_limit[max_channels]; + float err_max_soft_current_limit[max_channels]; + float err_min_slew[max_channels]; + float err_max_slew[max_channels]; + float err_min_load_type[max_channels]; + float err_max_load_type[max_channels]; + float err_min_vcc1[max_channels]; + float err_max_vcc1[max_channels]; + float err_min_vcc2[max_channels]; + float err_max_vcc2[max_channels]; + float err_min_vlogic[max_channels]; + float err_max_vlogic[max_channels]; + float composite_min_burst_time[max_channels]; /* minimum ever possible gap, taking into account all constraints */ +} ConstraintsStruct; + + typedef struct { + ConstraintsStruct Constraints; ChannelStruct ChannelState[max_channels]; FlashStruct Flash; int error_queue[error_queue_length+1]; int number_of_errors; /* how many errors are in the error queue */ + int extended_ampl_min_max; + int do_check_settings; } GlobalStruct; extern GlobalStruct globals; diff --git a/instr-daemon.c b/instr-daemon.c index 8205c9a..7f42a62 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -4,6 +4,7 @@ #include "flash.h" #include "globals.h" #include "bus.h" +#include "device-functions.h" #include <stdlib.h> #include <ctype.h> @@ -232,6 +233,7 @@ int main(int argc, char **argv) LCD_initialize(); bus_init(); initFlash (&globals.Flash, 0); + Main_Rst(); //register stdin channel stdinChannel = g_io_channel_unix_new(0); |