本文整理汇总了Python中config.config方法的典型用法代码示例。如果您正苦于以下问题:Python config.config方法的具体用法?Python config.config怎么用?Python config.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块config的用法示例。
在下文中一共展示了config.config方法的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
点赞 7
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def __init__(self):
self.currenttime = time.localtime()
printtime = time.strftime("%Y%m%d%H%M%S ", self.currenttime)
self.logfile = open(config['files']['logfile'],'at',buffering=1)
self.sampletime = time.time()
self.prevtime = time.localtime()
self.summary=loadsummary()
# summary = open('/media/75cc9171-4331-4f88-ac3f-0278d132fae9/summary','w')
# pickle.dump(hivolts, summary)
# pickle.dump(lowvolts, summary)
# summary.close()
if self.summary['hour']['timestamp'][0:10] != printtime[0:10]:
self.summary['hour'] = deepcopy(self.summary['current'])
if self.summary['currentday']['timestamp'][0:8] != printtime[0:8]:
self.summary['currentday'] = deepcopy(self.summary['current'])
if self.summary['monthtodate']['timestamp'][0:6] != printtime[0:6]:
self.summary['monthtodate'] = deepcopy(self.summary['current'])
if self.summary['yeartodate']['timestamp'][0:4] != printtime[0:4]:
self.summary['yeartodate'] = deepcopy(self.summary['current'])
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,
示例2: writesummary
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def writesummary(self):
""" Write summary file """
for section in summaryfile.sections():
for option in summaryfile.options(section):
summaryfile.set(section, option, str(self.summary[section][option]))
of = open(config['files']['summaryfile'],'w')
summaryfile.write(of)
of.close()
# def writehour(self, data):
# hoursummaryfile=open('/media/75cc9171-4331-4f88-ac3f-0278d132fae9/hoursummary','a')
# hoursummaryfile.write(data)
# hoursummaryfile.close()
# logsummary.set('alltime', 'maxvoltages') = round(max(literal_eval(logsummary.get('currentday','maxvoltages')),literal_eval(logsummary.get(),2)
# logsummary.set('alltime', 'minvoltages') = round(min(literal_eval(logsummary.get('currentday','minvoltages')),batdata.batvoltsav[8]),2)
# logsummary.set('alltime', 'ah') = round(max(literal_eval(logsummary.get('currentday','ah'))[1], batdata.soc/1000),2)
# logsummary.set('alltime', 'ah') = round(min(literal_eval(logsummary.get('currentday','ah'))[0], batdata.soc/1000),2)
# logsummary.set('alltime', 'current') = round(max(literal_eval(logsummary.get('alltime','current'))[1], batdata.currentav[-3]/1000),2)
# logsummary.set('alltime', 'current') = round(min(literal_eval(logsummary.get('alltime','current'))[0], batdata.currentav[-3]/1000),2)
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,
示例3: scanalarms
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def scanalarms(self,batdata):
# self.timedate = localtime()
# print (self.timedate.tm_hour)
for i in config['alarms']:
if not self.alarmtriggered[i]:
exec(config['alarms'][i][1])
# log.debug('{}{}{}'.format(self.test,batdata.maxcellv,batdata.lastmaxcellv))
if self.test:
# sys.stderr.write('Alarm 1 triggered')
log.info('alarm {} triggered'.format(i))
self.alarmtriggered[i]=True
exec(config['alarms'][i][2])
if self.alarmtriggered[i]:
exec(config['alarms'][i][3])
if self.test:
log.info('alarm {} reset'.format(i))
self.alarmtriggered[i]=False
exec(config['alarms'][i][4])
开发者ID:simat,项目名称:BatteryMonitor,代码行数:21,
示例4: getbmsdat
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def getbmsdat(self,port,command):
""" Issue BMS command and return data as byte data """
""" assumes data port is open and configured """
for i in range(5):
try:
port.write(command)
reply = port.read(4)
# raise serial.serialutil.SerialException('hithere')
break
except serial.serialutil.SerialException as err:
errfile=open(config['files']['errfile'],'at')
errfile.write(time.strftime("%Y%m%d%H%M%S ", time.localtime())+str(err.args)+'\n')
errfile.close()
# print (reply)
x = int.from_bytes(reply[3:5], byteorder = 'big')
# print (x)
data = port.read(x)
end = port.read(3)
# print (data)
return data
开发者ID:simat,项目名称:BatteryMonitor,代码行数:23,
示例5: findbms
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def findbms(self):
"""Scan ports to find BMS port"""
self.bmsport=""
for dev in glob.glob(config['Ports']['bmsport']):
for i in range(2):
try:
self.openbms(dev)
reply=self.getbmsdat(self.port,b'\x05\x00')
if reply.decode('ascii','strict')==self.sn:
self.bmsport=dev
break
except serial.serialutil.SerialException:
pass
finally:
self.port.close()
if self.bmsport!="":
break
if self.bmsport=="":
raise Exception("Couldn't find BMS hardware name {}".format(self.sn))
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,
示例6: findpip
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def findpip(self):
"""Scan ports to find PIP port"""
self.pipport=""
for dev in glob.glob(config['Ports']['pipport']):
for i in range(2):
try:
self.openpip(dev)
self.sendcmd("QID",18)
if self.reply[1:15].decode('ascii','strict')==str(self.sn):
self.pipport=dev
break
except serial.serialutil.SerialException:
pass
finally:
self.port.close
if self.pipport!="":
break
if self.pipport=="":
raise serial.serialutil.SerialException("Couldn't find PIP sn {}".format(self.sn))
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,
示例7: solaravailable
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def solaravailable(batdata):
"""Returns max amount of surpus solar energy available without using battery Power
Calculates the difference between amount of power being consumed vesus
power that could be consumed to get battery current=IBatZero"""
ibatminuteav=batdata.ibatminute/batdata.ibatnuminmin
batdata.ibatminute = 0.0
batdata.ibatnuminmin = 0
iavailable=(IBatZero-ibatminuteav)
soc=1-batdata.socadj/config['battery']['capacity']
iavailable=iavailable+config['battery']['maxchargerate']* \
(soc-config['battery']['targetsoc'])*20
pwravailable=iavailable*batdata.batvoltsav[config['battery']['numcells']+1]
# print (iavailable,soc,pwravailable)
return pwravailable
开发者ID:simat,项目名称:BatteryMonitor,代码行数:18,
示例8: create_app
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def create_app(config_name):
app = Flask(__name__)
#app.config['JSON_AS_ASCII'] = False
# 进行app配置 把自己的config设定导入到app中
app.config.from_object(config[config_name])
# 初始化app配置
config[config_name].init_app(app)
db.init_app(app)
db.app = app
# 初始化apscheduler
scheduler.init_app(app)
scheduler.start()
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .job import main as job_blueprint
app.register_blueprint(job_blueprint,url_prefix='/v1/cron/job')
return app
开发者ID:yangmv,项目名称:CTask,代码行数:25,
示例9: train_network
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def train_network(self, learning_rate, decay_rate, start_epoch=None):
# weights_path = "weights/{0}-rerun-test.h5".format(learning_rate)
# log_path = "logs/{0}-rerun-test".format(learning_rate)
tensorboard = keras.callbacks.TensorBoard(log_dir=config['log_path'],
histogram_freq=0,
write_graph=True,
write_images=False)
checkpointer = keras.callbacks.ModelCheckpoint(filepath=config['weights_path'],
verbose=1,
save_best_only=True)
self.model.fit_generator(self.next_train_batch(chunk_size=16),
samples_per_epoch=int(self.train_size/5),
nb_epoch=self.num_epochs,
validation_data=self.next_validation_batch(chunk_size=32),
nb_val_samples=int(self.validation_size/5),
callbacks=[checkpointer, tensorboard])
# learning_rate = 0.001
# decay_rate = 0.001
# neural_net = NeuralNetwork(learning_rate, decay_rate)
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:22,代码来源:nn.py
示例10: resize_images
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def resize_images(paths):
for path in paths:
if os.path.isfile(path) and os.path.getsize(path) > 0:
filename, ext = os.path.splitext(path)
image_size = "_{0}".format(config['image_size'])
new_filename = filename + image_size + ext
if not os.path.exists(new_filename) or os.path.getsize(new_filename) == 0:
# if the file hasn't been resized
# or the resized version is corrupt (i.e. zero size)
if image_size not in filename:
try:
image = Image.open(path)
image = image.resize(config['image_size_tuple'])
image.save(filename + image_size + ext)
except OSError:
print("OSError caused by file at {0}".format(path))
continue
# if OSError:
# cannot identify image file occurs despite above checks, skip the image
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:21,
示例11: colour_images
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def colour_images(paths):
for path in paths:
if os.path.isfile(path) and os.path.getsize(path) > 0:
filename, ext = os.path.splitext(path)
image_size = "_{0}".format(config['image_size'])
if image_size in filename:
try:
image = Image.open(path)
if image.mode != "RGB":
image = image.convert("RGB")
image.save(filename + ext)
except OSError:
print("OSError caused by file at {0}".format(path))
continue
# if OSError:
# cannot identify image file occurs despite above checks, skip the image
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:18,
示例12: run
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def run():
"""
生产模式启动命令函数
To use: python3 manager.py run
"""
app.logger.setLevel(app.config.get('LOG_LEVEL', logging.INFO))
service_config = {
'bind': app.config.get('BIND', '0.0.0.0:5000'),
'workers': app.config.get('WORKERS', cpu_count() * 2 + 1),
'worker_class': 'gevent',
'worker_connections': app.config.get('WORKER_CONNECTIONS', 10000),
'backlog': app.config.get('BACKLOG', 2048),
'timeout': app.config.get('TIMEOUT', 60),
'loglevel': app.config.get('LOG_LEVEL', 'info'),
'pidfile': app.config.get('PID_FILE', 'run.pid'),
}
StandaloneApplication(app, service_config).run()
开发者ID:lalala223,项目名称:flask-restful-example,代码行数:19,
示例13: check_OP_1_Connection
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def check_OP_1_Connection():
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "Connecting.....", font=getFont(), fill='white')
displayImage(connected)
# if is_connected():
if do_mount("OP1"):
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "Connected", font=getFont(), fill='white')
displayImage(connected)
return True
else:
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "No Connection!", font=getFont(), fill='white')
displayImage(connected)
config["USB_Mount_Path"] = ""
config["OP_1_Mounted_Dir"] = ""
time.sleep(1)
return False
开发者ID:adwuard,项目名称:OP_Manager,代码行数:24,
示例14: check_OP_Z_Connection
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def check_OP_Z_Connection():
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "Connecting.....", font=getFont(), fill='white')
displayImage(connected)
if do_mount("OPZ"):
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "Connected", font=getFont(), fill='white')
displayImage(connected)
time.sleep(1)
return True
else:
connected = Image.new('1', (128, 64))
draw = ImageDraw.Draw(connected)
draw.text((0, 25), "No Connection!", font=getFont(), fill='white')
displayImage(connected)
config["USB_Mount_Path"] = ""
time.sleep(1)
return False
开发者ID:adwuard,项目名称:OP_Manager,代码行数:22,
示例15: autoMountUnmontThread
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def autoMountUnmontThread():
while 1:
print("Unmount Checking Thread")
# if config["OP_1_Mounted_Dir"] == "":
# if do_mount("OP1"):
# print("============ Thread OP1 Mounted ==============")
# else:
# print("============ Thread Waiting OP1 ==============")
# if config["OP_Z_Mounted_Dir"] == "":
# if do_mount("OPZ"):
# print("============ Thread OPZ Mounted ==============")
# else:
# print("============ Thread Waiting OPZ ==============")
# Device Mounted check for unmount
if config["OP_1_Mounted_Dir"] != "":
if not os.listdir(config["OP_1_Mounted_Dir"]):
unmountdevice(config["OP_1_Mounted_Dir"])
config["OP_1_Mounted_Dir"] = ""
print("============ Thread OP1 Auto Unmount==============")
if config["OP_Z_Mounted_Dir"] != "":
if not os.listdir(config["TargetOpZMountDir"]):
unmountdevice(config["OP_Z_Mounted_Dir"])
config["OP_z_Mounted_Dir"] = ""
print("============ Thread OPZ Auto Unmount==============")
time.sleep(3)
开发者ID:adwuard,项目名称:OP_Manager,代码行数:27,
示例16: loadStateToOPZ
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def loadStateToOPZ(self, localPath):
OPZStatePath = config["OP_Z_Mounted_Dir"]
print("Load local to OPZ")
print(localPath)
print(OPZStatePath)
for root, dirs, files in os.walk(OPZStatePath):
for f in files:
print("remove", f)
os.unlink(os.path.join(root, f))
for d in dirs:
print("remove Dir", d)
shutil.rmtree(os.path.join(root, d))
print("OPZ Dir Cleared")
print("Copying to OPZ")
copytree(localPath, OPZStatePath)
print("Finished Copying to OPZ")
开发者ID:adwuard,项目名称:OP_Manager,代码行数:18,
示例17: process_video
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def process_video(video_dict, user_config):
"""
处理直播视频,包含bot的发送,视频下载,视频上传和存入数据库
:param video_dict: 含有直播视频数据的dict
:param user_config: 用户配置
:return: None
"""
assert 'bot_notice' in user_config
assert 'download' in user_config
bot(f"[直播提示] {video_dict['Provide']}{video_dict.get('Title')} 正在直播 链接: {video_dict['Target']} [CQ:at,qq=all]", user_config)
ddir = get_ddir(user_config)
check_ddir_is_exist(ddir)
logger = logging.getLogger('run.precess_video')
logger.info(f'{video_dict["Provide"]} Found A Live, starting downloader')
video_dict['Title'] = AdjustFileName(video_dict['Title']).adjust(ddir)
if video_dict["Provide"] == 'Youtube':
downloader(r"https://www.youtube.com/watch?v=" + video_dict['Ref'], video_dict['Title'], config['proxy'], ddir, user_config, config['youtube']['quality'])
else:
downloader(video_dict['Ref'], video_dict['Title'], config['proxy'], ddir, user_config)
if config['enable_upload']:
v = VideoUpload(video_dict, user_config)
v.start()
开发者ID:fzxiao233,项目名称:Auto_Record_Matsuri,代码行数:24,
示例18: gen_process
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def gen_process(self):
if config['youtube']['enable']:
for user_config in config['youtube']['users']:
y = Youtube(user_config)
self.events_multi.append(y)
if config['twitcasting']['enable']:
for user_config in config['twitcasting']['users']:
t = Twitcasting(user_config)
self.events_multi.append(t)
if config['openrec']['enable']:
for user_config in config['openrec']['users']:
o = Openrec(user_config)
self.events_multi.append(o)
if config['mirrativ']['enable']:
for user_config in config['mirrativ']['users']:
m = Mirrativ(user_config)
self.events_multi.append(m)
if config['bilibili']['enable']:
for user_config in config['bilibili']['users']:
b = Bilibili(user_config)
self.events_multi.append(b)
开发者ID:fzxiao233,项目名称:Auto_Record_Matsuri,代码行数:23,
示例19: start_temp_daemon
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def start_temp_daemon():
db = Database('Queues')
while True:
event = []
for target_url in db.select():
p = YoutubeTemp(target_url)
event.append(p)
p.daemon = True
p.start()
is_running = True
while is_running:
has_running = False
for p in event:
if p.is_alive():
has_running = True
if not has_running:
is_running = False
logger.info('A check has finished.')
sleep(config['sec'])
开发者ID:fzxiao233,项目名称:Auto_Record_Matsuri,代码行数:21,
示例20: upload_video
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def upload_video(video_dict, user_config):
upload_way_dict = {'bd': BDUpload,
's3': S3Upload}
upload_way = upload_way_dict.get(config['upload_by'])
uploader = upload_way()
ddir = get_ddir(user_config)
uploader.upload_item(f"{ddir}/{video_dict['Title']}", video_dict['Title'])
if config['upload_by'] == 'bd':
share_url = uploader.share_item(video_dict['Title'])
if config['enable_mongodb']:
db = Database(user_map(video_dict['User']))
db.insert(video_dict['Title'], share_url, video_dict['Date'])
elif config['upload_by'] == 's3':
if config['enable_mongodb']:
db = Database(user_map(video_dict['User']))
db.insert(video_dict['Title'],
f"gets3/{quote(video_dict['Title'])}",
video_dict['Date'])
else:
raise RuntimeError(f'Upload {video_dict["Title"]} failed')
bot(f"[下载提示] {video_dict['Title']} 已上传, 请查看https://matsuri.design/", user_config)
开发者ID:fzxiao233,项目名称:Auto_Record_Matsuri,代码行数:23,
示例21: create_app
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
bootstrap.init_app(app)
moment.init_app(app)
db.init_app(app)
login_manager.init_app(app)
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
app.register_blueprint(auth_blueprint, url_prefix='/qrcode')
from .api_1_0 import api as api_1_0_blueprint
app.register_blueprint(api_1_0_blueprint, url_prefix='/v1')
from .plugins import plugins as plugins_blueprint
app.register_blueprint(plugins_blueprint, url_prefix='/plugins')
return app
开发者ID:jpush,项目名称:jbox,代码行数:21,
示例22: create_app
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def create_app(env):
app = Flask(__name__)
app.config.from_object(config[env])
# Start api/v1 Blueprint
api_bp = Blueprint('api', __name__)
api = Api(api_bp)
api.add_resource(auth.AuthLogin, '/auth/login')
api.add_resource(auth.AuthRegister, '/auth/register')
api.add_resource(files.CreateList, '/users//files')
api.add_resource(files.ViewEditDelete, '/users//files/')
app.register_blueprint(api_bp, url_prefix="/api/v1")
# End api/v1 Blueprint
return app
开发者ID:afropolymath,项目名称:papers,代码行数:19,
示例23: create_app
点赞 6
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
bootstrap.init_app(app)
mail.init_app(app)
moment.init_app(app)
db.init_app(app)
login_manager.init_app(app)
pagedown.init_app(app)
if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
from flask_sslify import SSLify
sslify = SSLify(app)
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
return app
开发者ID:KevDi,项目名称:Flashcards,代码行数:25,
示例24: writeperiod
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def writeperiod(self, file, data):
""" Append 'data' to 'file' for previous period """
periodfile=open(config['files'][file],'a')
writestr=''
y = summaryfile.items(data)
for i in y:
writestr = writestr + str(i) +"\n"
writestr = writestr + "\n"
periodfile.write(writestr)
periodfile.close()
开发者ID:simat,项目名称:BatteryMonitor,代码行数:12,
示例25: startmonth
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def startmonth(self, summary):
""" Start new month """
self.writeperiod('monthsummaryfile', 'monthtodate')
summary['monthtodate']['ah'][3] = 0 # zero number of samples for av
summary['monthtodate'] = deepcopy(summary['current'])
filecopy(config['files']['summaryfile'],config['files']['summaryfile']+ self.printtime[0:8])
开发者ID:simat,项目名称:BatteryMonitor,代码行数:9,
示例26: __init__
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def __init__(self,batdata,summary):
self.summary=summary
self.alarmtriggered={}
for i in config['alarms']:
self.alarmtriggered[i]=False
exec(config['alarms'][i][0])
log.info('alarm {} initialised'.format(i))
# config['alarms'][i][1] = compile(config['alarms'][i][1], '', 'exec')
# config['alarms'][i][2] = compile(config['alarms'][i][2], '', 'exec')
# config['alarms'][i][3] = compile(config['alarms'][i][3], '', 'exec')
# config['alarms'][i][4] = compile(config['alarms'][i][4], '', 'exec')
开发者ID:simat,项目名称:BatteryMonitor,代码行数:13,
示例27: avv
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def avv():
vstr=""
v=[0.0 for i in range(numcells+1)]
endlog=tail(config['files']['logfile'],11)
for j in range(1,numcells+1):
for i in range(10):
x=float(endlog[i][(j-1)*6+15:(j-1)*6+20])+config['calibrate']['delta'][j-1]
v[j]=v[j]+x
for i in range(1,len(v)):
v[i]=v[i]/10+v[i-1]
vstr=vstr+str(i) + "=" +str(round(v[i],3)).ljust(5,'0') + ", "
print(vstr)
print(config['calibrate']['measured'])
print(config['calibrate']['displayed'])
return v
开发者ID:simat,项目名称:BatteryMonitor,代码行数:17,
示例28: main
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def main():
print('Usage: Pressing just the [Enter] key will display the latest voltage readings, type ^C to exit')
print(' Type in the cell # that you want to calibrate followed by [Enter]')
print(' Then type in the mesured voltage for that cell followed by [Enter]')
print()
print(' Make sure the Battery Monitoring software is running otherwise the summary file will not be current')
print(' This program uses the data from the log file generated by the Battery Monitoring software')
print(' Make sure that the Battery Monitoring software is logging to a real file and not /dev/null')
print(' This program averages the data from the log file for the last 100 seconds.')
print(' To make sure that the calibration is accurate make sure the input voltages are not varying')
avvolts=[]
while True:
try:
loadconfig()
avvolts=avv()
# time.sleep(60.0)
what = input(">")
if len(what)>0:
realvolts = eval(input("Cell " + what + " reading "))
what=int(what)
config['calibrate']['measured'][what] = round(realvolts,3)
config['calibrate']['displayed'][what] = round(avvolts[what],3)
batconfigdata=SafeConfigParser()
batconfigdata.read('battery.cfg')
batconfigdata.set('calibrate','measured',str(config['calibrate']['measured']))
batconfigdata.set('calibrate','displayed',str(config['calibrate']['displayed']))
with open('battery.cfg', 'w') as batconfig:
batconfigdata.write(batconfig)
batconfig.closed
except KeyboardInterrupt:
break
开发者ID:simat,项目名称:BatteryMonitor,代码行数:35,
示例29: getvi
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def getvi(self):
""" Get raw data """
self.oldsampletime=self.sampletime
sleeptime = max(config['sampling']['sampletime'] - (time.time()-self.oldsampletime), 0.0)
# sleeptime
time.sleep(sleeptime)
self.sampletime = time.time()
# get data from Interfaces
for i in config['Interfaces']:
exec('self.'+i+".getdata()")
for i in range(len(self.iin)):
self.current[i] = eval(self.iin[i]) \
*config['calibrate']['currentgain'][i] \
-config['calibrate']['currentoffset'][i]
# self.batvolts[0] = self.rawdata.rawv[0]
# self.uncalvolts[0] = self.rawdata.rawv[0]
# self.batvolts[0] = 0.0
# self.uncalvolts[0] = 0.0
for i in range(len(self.vin)):
self.uncalvolts[i+1] = eval(self.vin[i]) \
*config['calibrate']['batvgain'] # A/D to battery volts
self.batvolts[i+1] = self.uncalvolts[i+1]*self.ratio[i] # calibrate values
for i in range(len(self.tin)): # get temperatures
self.temp[i] = eval(self.tin[i])
for i in range(numcells): # get balance flags
self.balflg[i] = eval(self.balf[i])
for i in range(len(self.chgstat)): # get PIP charge states
self.chargestates[i]=eval(self.chgstat[i])
开发者ID:simat,项目名称:BatteryMonitor,代码行数:34,
示例30: __init__
点赞 5
# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def __init__(self,sn):
self.rawdat={'DataValid':False,'V00':0.0}
self.sn=sn
self.findbms()
"""port=self.openbms(config['files']['usbport'])
data=self.getbmsdat(port,b'\x04\x00') # get BMS voltages
port.close()
self.rawdat={'V'+str(x+1):0.0 for x in range(int(len(data)/2))}
self.rawdat['Ibat']=0.0"""
开发者ID:simat,项目名称:BatteryMonitor,代码行数:12,
注:本文中的config.config方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。