本文整理汇总了Python中gladevcp.persistence.IniFile.save_state方法的典型用法代码示例。如果您正苦于以下问题:Python IniFile.save_state方法的具体用法?Python IniFile.save_state怎么用?Python IniFile.save_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gladevcp.persistence.IniFile
的用法示例。
在下文中一共展示了IniFile.save_state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gladevcp.persistence import IniFile [as 别名]
# 或者: from gladevcp.persistence.IniFile import save_state [as 别名]
class PWMClass:
def __init__(self,halcomp,builder,useropts):
self.builder = builder
self.halcomp = halcomp
self.defaults = { IniFile.vars : {"laser_milliseconds" : 166}}
self.ini_filename = __name__ + ".var"
self.ini = IniFile(self.ini_filename,self.defaults,self.builder)
self.ini.restore_state(self)
self.laser_hertz_value = hal_glib.GPin(halcomp.newpin("laser_hertz_value", hal.HAL_U32, hal.HAL_OUT))
self.lbl_duration_value = self.builder.get_object("lbl_duration_value")
# sets what got loaded in from the ini_file
self.calc_and_set_milliseconds(self.laser_milliseconds)
# self.btn1 = self.builder.get_object("period_50")
# self.btn1.connect("pressed", self.on_btn_pressed, 50)
self.btn1 = self.builder.get_object("period_50")
self.btn1.connect("pressed", self.on_btn_pressed, 50)
self.btn1 = self.builder.get_object("period_100")
self.btn1.connect("pressed", self.on_btn_pressed, 100)
self.btn1 = self.builder.get_object("period_200")
self.btn1.connect("pressed", self.on_btn_pressed, 200)
self.btn1 = self.builder.get_object("period_500")
self.btn1.connect("pressed", self.on_btn_pressed, 500)
self.btn1 = self.builder.get_object("period_700")
self.btn1.connect("pressed", self.on_btn_pressed, 700)
self.btn1 = self.builder.get_object("period_900")
self.btn1.connect("pressed", self.on_btn_pressed, 900)
self.box = self.builder.get_object("tbl_marius") # arbitrary object to test for ending
self.box.connect("destroy", self._on_destroy)
def calc_and_set_milliseconds(self, value):
self.laser_milliseconds = value
if (self.laser_milliseconds < 20):
self.laser_milliseconds = 20
if (self.laser_milliseconds > 990):
self.laser_milliseconds = 990
self.halcomp["laser_hertz_value"] = (1000000 / self.laser_milliseconds)
self.lbl_duration_value.set_label("%d" % self.laser_milliseconds)
os.system("halcmd setp hm2_5i20.0.pwmgen.pwm_frequency %d" % self.halcomp["laser_hertz_value"])
def on_btn_pressed(self, pin, value):
self.calc_and_set_milliseconds(value)
def on_unix_signal(self,signum,stack_frame):
print "on_unix_signal(): signal %d received, saving state" % (signum)
self.ini.save_state(self)
def _on_destroy(self, obj, data = None):
self.ini.save_state(self)
示例2: __init__
# 需要导入模块: from gladevcp.persistence import IniFile [as 别名]
# 或者: from gladevcp.persistence.IniFile import save_state [as 别名]
#.........这里部分代码省略.........
self.btn_pierce_delay_plus = self.builder.get_object("btn_pierce_delay_plus")
self.btn_pierce_delay_plus.connect("pressed", self.on_btn_pierce_delay_pressed, 1)
self.adj_pierce_delay = self.builder.get_object("adj_pierce_delay")
self.adj_pierce_delay.connect("value_changed", self.on_adj_pierce_delay_value_changed)
self.adj_pierce_delay.upper = self.piercedelaymax
self.adj_pierce_delay.lower = self.piercedelaymin
self.adj_pierce_delay.set_value(self.piercedelayval)
self.enable_HeightLock = self.builder.get_object("enable-HeightLock")
self.enable_HeightLock.connect("toggled", self.on_enable_HeightLock_toggled)
self.enable_HeightLock.set_active(self.enableheightlock)
self.adj_CHL_threshold = self.builder.get_object("adj_CHL_threshold")
self.adj_CHL_threshold.connect("value_changed", self.on_adj_CHL_threshold_value_changed)
self.adj_CHL_threshold.upper = self.chlthresholdmax
self.adj_CHL_threshold.lower = self.chlthresholdmin
self.adj_CHL_threshold.set_value(self.chlthresholdval)
self.btn_THC_target_minus = self.builder.get_object("btn_THC_target_minus")
self.btn_THC_target_minus.connect("pressed", self.on_btn_THC_target_pressed, -1)
self.btn_THC_target_plus = self.builder.get_object("btn_THC_target_plus")
self.btn_THC_target_plus.connect("pressed", self.on_btn_THC_target_pressed, 1)
self.adj_THC_Voltage = self.builder.get_object("adj_THC_Voltage")
self.adj_THC_Voltage.connect("value_changed", self.on_adj_THC_Voltage_value_changed)
self.adj_THC_Voltage.upper = self.thctargetvoltmax
self.adj_THC_Voltage.lower = self.thctargetvoltmin
self.adj_THC_Voltage.set_value(self.thctargetvoltval)
def _on_destroy(self, obj, data = None):
self.ini.save_state(self)
# What to do on button pres events?
def on_btn_THC_speed_pressed(self, widget, dir):
increment = self.thcspeedincr * dir
self.thcspeedval = self.adj_THC_speed.get_value() + increment
self.adj_THC_speed.set_value(self.thcspeedval)
def on_btn_cut_gap_pressed(self, widget, dir):
increment = self.cutgapincr * dir
self.cutgapval = self.adj_cut_gap.get_value() + increment
self.adj_cut_gap.set_value(self.cutgapval)
def on_btn_g0_pressed(self, widget, dir):
increment = self.g0gapincr * dir
self.g0gapval = self.adj_G0_gap.get_value() + increment
self.adj_G0_gap.set_value(self.g0gapval)
def on_btn_pierce_gap_pressed(self, widget, dir):
increment = self.piercegapincr * dir
self.piercegapval = self.adj_pierce_gap.get_value() + increment
self.adj_pierce_gap.set_value(self.piercegapval)
def on_btn_pierce_delay_pressed(self, widget, dir):
increment = self.piercedelayincr * dir
self.piercedelayval = self.adj_pierce_delay.get_value() + increment
self.adj_pierce_delay.set_value(self.piercedelayval)
def on_btn_THC_target_pressed(self, widget, dir):
increment = self.thctargetvoltincr * dir
self.thctargetvoltval = self.adj_THC_Voltage.get_value() + increment
self.adj_THC_Voltage.set_value(self.thctargetvoltval)
示例3: __init__
# 需要导入模块: from gladevcp.persistence import IniFile [as 别名]
# 或者: from gladevcp.persistence.IniFile import save_state [as 别名]
#.........这里部分代码省略.........
self.adj_spin_oneshot = self.builder.get_object("spin_adjust")
self.adj_spin_oneshot.connect("value_changed", self.on_adj_spin_oneshot_value_changed)
self.adj_spin_oneshot.set_value(self.spin_oneshot_time)
self.adj_laser_power = self.builder.get_object("slide_adjust")
self.adj_laser_power.connect("value_changed", self.on_adj_laser_power_value_changed)
self.adj_laser_power.upper = self.laser_power_max
self.adj_laser_power.lower = self.laser_power_min
self.adj_laser_power.set_value(self.laser_power_val)
if os.getenv('INI_FILE_NAME'):
ini_file = os.getenv('INI_FILE_NAME')
else:
self.lbl_program_name.set_label("INI_FILE_NAME not set?")
if os.path.isfile(ini_file):
config = ConfigParser.ConfigParser()
config.read(ini_file)
if config.has_option('DISPLAY','PROGRAM_PREFIX') and config.has_option('DISPLAY','PROGRAM_DEFAULT'):
prefix = config.get('DISPLAY','PROGRAM_PREFIX')
prog = config.get('DISPLAY','PROGRAM_DEFAULT')
self.target_path = os.path.join(prefix, prog)
else:
self.lbl_program_name.set_label("ncfile not found")
glib.timeout_add_seconds(1, self.on_timer_tick)
def human_readable_file_date(self, f):
seconds = int(float(time.time()) - float(os.path.getmtime(f)))
value = ''
if seconds < 10:
value = 'NEW'
elif seconds < 60:
value = '%d sec' % seconds
elif seconds < (60 * 2):
value = '%d min' % (seconds / 60)
elif seconds < (2 * 60 * 60):
value = '%d mins' % (seconds / 60)
elif seconds > (60 * 60 * 60):
value = '%dh' % (seconds / (60 * 60 * 60))
else:
value = 'age?'
return (value)
# chows the thing.ngc file and finds the numth occurance of
# of a comment in the form "^(text)"
def extract_headline(self, file_name, num):
f = open(file_name, "r")
tag = self.human_readable_file_date(file_name)
count = 0
for line in f.read().splitlines():
if re.match("^\(.*", line):
if count == (num - 1):
line = re.sub('[\(\))]', '', line)
return('%s (%s)' % (line, tag))
count += 1
def on_btn_squealer_pressed(self, pin, data = None):
print "poked squealer button"
def on_timer_tick(self,userdata=None):
if os.path.isfile(self.target_path):
r = self.extract_headline(self.target_path, 1)
if r:
self.lbl_program_name.set_label(r)
return True # True restarts the timer
def _on_destroy(self, obj, data = None):
self.ini.save_state(self)
def on_btn_chiller_pressed(self, pin, data = None):
print self.halcomp["chiller.is-on"]
def on_mbtn_laser_pressed(self, pin, data = None):
# for milli seconds
self.halcomp["laser_pulse_width"] = self.halcomp["spin_oneshot_time-s"] / float(1000)
# for seconds
# self.halcomp["laser_pulse_width"] = self.halcomp["spin_oneshot_time-s"] / float(1)
if self.halcomp["chkbtn_oneshot"]:
self.halcomp["laser_on_cont"] = 0
self.halcomp["laser_on_pulse"] = 1
else:
self.halcomp["laser_on_cont"] = 1
self.halcomp["laser_on_pulse"] = 0
def on_mbtn_laser_released(self, pin, data = None):
self.halcomp["laser_on_cont"] = 0
self.halcomp["laser_on_pulse"] = 0
def on_adj_laser_power_value_changed(self, pin, data = None):
self.laser_power_val = pin.get_value()
def on_adj_spin_oneshot_value_changed(self, pin, data = None):
self.spin_oneshot_time = pin.get_value()
def on_unix_signal(self,signum,stack_frame):
print "on_unix_signal(): signal %d received, saving state" % (signum)
self.ini.save_state(self)