class ModbusHandler:
    def __init__(self):
        self.config = GlobalConfig()
        self.master = modbus_tcp.TcpMaster(
            host=self.config.getModbusInfo('MODBUS_ADDRESS'), port=502)

    def getAnalogInputs(self):
        data = self.master.execute(255, cst.READ_HOLDING_REGISTERS, 8335, 10)
        now = datetime.datetime.now()
        return {
            "logs": self.buildLogPack(data),
            "datetime": "%s-05" % now.strftime("%Y-%m-%d %H:%M:%S")
        }

    def buildLogPack(self, IO_DATA):
        logPack = {}
        for x in range(int(self.config.getModbusInfo('NUM_OF_AI'))):
            aiNum = x + 1
            aiInfo = self.config.getInputInfo("AI_" + str(aiNum))
            if (bool(aiInfo["active"])):
                logPack[aiInfo["point_id"]] = {
                    "name": aiInfo["name"],
                    "value": IO_DATA[x] / 10,
                    "unit": aiInfo["unit"]
                }
        return logPack
Exemple #2
0
class Logger:
    def __init__(self):
        self.config = GlobalConfig()
        self.ModbusDevice = ModbusHandler()

    def log(self):
        data = self.ModbusDevice.getAnalogInputs()
        logging.info("Logging: \n %s" % data)
        requests.post(self.config.getEnvVars('SERVER_ADDRESS') + '/log/test',
                      json=data)

    def run(self, delay=10):
        self.log()
        time.sleep(int(self.config.getEnvVars('FREQUENCY')))
        self.run()
Exemple #3
0
    def Init(self):
        """
        """
        self.gconfig = GlobalConfig.instance()
        znetlib = self.gconfig.GetValue('CONFIG', 'net-lib')
        gate_ip = self.gconfig.GetValue('CONFIG', 'gate-server-address')
        gate_port = self.gconfig.GetValue('CONFIG', 'gate-server-port')

        self.nclient = net_client(znetlib)
        nc_arg = nc_arg_t()
        nc_arg.ip = gate_ip
        nc_arg.port = gate_port
        rv = self.nclient.nc_connect(nc_arg)
        if not rv:
            PutLogList("(*) Connect to server IP:%s PORT:%d failed!" %
                       (gate_ip, gate_port))
            return False

        self.scmanager = SceneManager.instance()
        rv = self.scmanager.Init()
        if not rv:
            return False

        self.gatelogic = GateLogic.instance()
        rv = self.gatelogic.Init()
        if not rv:
            return False

        if not self.RegisterGS():
            return False

        return True
Exemple #4
0
    def __init__(self,scene_cfg):
	self.mutex_players = threading.Lock() 
	self.scene_cfg = scene_cfg
	self.scene = {}
	self.players = {}
	self.offline_players = []

	self.qobjects = {}
	self.npc_manager = NPCManager()

        self.gconfig = GlobalConfig.instance()
	self.qdtreelib = self.gconfig.GetValue('CONFIG','qdtree-lib')

	self.load_scene(scene_cfg)
	self.qdtree = quadtree.quadtree(self.qdtreelib);
	box = quadtree.quad_box_t()
	box._xmin = self.xmin
	box._xmax = self.xmax
	box._ymin = self.ymin
	box._ymax = self.ymax
	self.qdtree.quadtree_create(box,5,0.1)

	self.uuid = uuid.instance()

        from GateLogic import GateLogic
	from StoreClient import StoreClient
	self.gatelogic = GateLogic.instance()
	self.storeclient = StoreClient.instance()
Exemple #5
0
    def Init(self):
        """
        """
        self.gconfig = GlobalConfig.instance()
	znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	gate_ip = self.gconfig.GetValue('CONFIG','gate-server-address')
	gate_port = self.gconfig.GetValue('CONFIG','gate-server-port')
        
	self.nclient = net_client(znetlib)
	nc_arg = nc_arg_t()
	nc_arg.ip = gate_ip
	nc_arg.port = gate_port
	rv = self.nclient.nc_connect(nc_arg)
	if not rv:
	    PutLogList("(*) Connect to server IP:%s PORT:%d failed!" % (gate_ip,
		gate_port))
	    return False

	self.scmanager = SceneManager.instance()
	rv = self.scmanager.Init()
	if not rv:
	    return False

	self.gatelogic = GateLogic.instance()
	rv = self.gatelogic.Init()
	if not rv:
	    return False

	if not self.RegisterGS():
	    return False

	return True
Exemple #6
0
    def __init__(self, scene_cfg):
        self.mutex_players = threading.Lock()
        self.scene_cfg = scene_cfg
        self.scene = {}
        self.players = {}
        self.offline_players = []

        self.qobjects = {}
        self.npc_manager = NPCManager()

        self.gconfig = GlobalConfig.instance()
        self.qdtreelib = self.gconfig.GetValue('CONFIG', 'qdtree-lib')

        self.load_scene(scene_cfg)
        self.qdtree = quadtree.quadtree(self.qdtreelib)
        box = quadtree.quad_box_t()
        box._xmin = self.xmin
        box._xmax = self.xmax
        box._ymin = self.ymin
        box._ymax = self.ymax
        self.qdtree.quadtree_create(box, 5, 0.1)

        self.uuid = uuid.instance()

        from GateLogic import GateLogic
        from StoreClient import StoreClient
        self.gatelogic = GateLogic.instance()
        self.storeclient = StoreClient.instance()
Exemple #7
0
def getList():
	cfg = GlobalConfig()
	result = cfg.get('indexs')

	if result is None:
		try:
			result = []
			from XlsHelper import XlsHelper
			table = XlsHelper('NameList.xls').read(index = 0)
			for i in range(table.nrows):
				row = table.row_values(i)
				code = row[0]
				name = row[1]
				result.append({code:name})
			cfg.set('indexs', result)
		except Exception, e:
			print e
			result = indexsBackup
Exemple #8
0
	def Init(self):
            from ClientManager import ClientManager
	    self.gconfig = GlobalConfig.instance()
	    self.serverid = self.gconfig.GetValue('CONFIG','server-id')
	    self.uuid = uuid.instance()

	    self.clientmanager = ClientManager.instance()
	    self.nserver = self.clientmanager.nserver
	    self.storeclient = StoreClient.instance()
	    return True
    def Init(self):
        from ClientManager import ClientManager
        self.gconfig = GlobalConfig.instance()
        self.serverid = self.gconfig.GetValue('CONFIG', 'server-id')
        self.uuid = uuid.instance()

        self.clientmanager = ClientManager.instance()
        self.nserver = self.clientmanager.nserver
        self.storeclient = StoreClient.instance()
        return True
Exemple #10
0
	def Init(self):
	    from wgserver import WGServer
	    from StoreClient import StoreClient
            self.gconfig = GlobalConfig.instance()
	    self.serverid = self.gconfig.GetValue('CONFIG','gsid')

	    self.uuid = uuid.instance()
	    self.scmanager = SceneManager.instance()
	    self.nclient = WGServer.instance().nclient
	    self.storeclient = StoreClient.instance()
	    return True
Exemple #11
0
class ModbusHandler:
    def __init__(self, controller):
        self.config = GlobalConfig()
        self.envVars = self.config.getEnvVars()
        if (controller):
            self.controller = controller

    def getLogPackage(self, controllers):
        now = datetime.datetime.now()
        logPackage = {}
        for controller in controllers:
            self.controller = controller
            self.setConnection()
            rawData = self.getAnalogInputs()
            logPackage['logs'] = self.getLogBlock(rawData)
        logPackage['datetime'] = "%s-05" % now.strftime("%Y-%m-%d %H:%M:%S")
        return logPackage

    def setConnection(self):
        print("Connecting to: " + self.controller['MODBUS_ADDRESS'] + ":" +
              str(self.controller['MODBUS_PORT']))
        self.master = modbus_tcp.TcpMaster(
            host=self.controller['MODBUS_ADDRESS'],
            port=int(self.controller['MODBUS_PORT']))

    def getAnalogInputs(self):
        return self.master.execute(255, cst.READ_HOLDING_REGISTERS, 8959, 29)

    def getLogBlock(self, dataArray):
        inputs = self.controller['inputs']
        logBlock = {}
        # Add in analog sections
        for x in range(len(dataArray)):
            pos = x + 1
            inputID = self.calcInputID(pos)
            if inputID not in inputs:
                continue
            pointInfo = inputs[inputID]
            if (pointInfo and pointInfo['point_id']):
                logBlock[pointInfo["point_id"]] = {"value": dataArray[x]}
        return logBlock

    def calcInputID(self, pos):
        controller = self.controller
        inputID = ''
        if (pos <= controller['NUM_OF_AI']):
            inputID = "AI_" + str(pos)
        elif (pos <= (controller['NUM_OF_AI'] + controller['NUM_OF_DI'])):
            inputID = "DI_" + str(pos - controller['NUM_OF_AI'])
        else:
            inputID = "CUST_" + str(pos - (
                (controller['NUM_OF_AI'] + controller['NUM_OF_DI'])))
        return inputID
Exemple #12
0
    def getPath(self, name):
        import os
        path = 'Smaug/%s.txt' % name

        mode = GlobalConfig().get('mode')
        if mode == 'Hobbit':
            path = 'Hobbit/%s.txt' % name

        if os.path.isfile(path):
            return path
        else:
            raise TypeError(path)
Exemple #13
0
def main():
    """ entry point """

    # ============================ Config loading =============================

    if not os.path.isfile(config_path):
        # copy the default config
        if not os.path.isfile(default_config_path):
            print "[pihud] Fatal: Missing default config file. Try reinstalling"
            sys.exit(1)
        else:
            shutil.copyfile(default_config_path, config_path)

    global_config = GlobalConfig(config_path)

    # =========================== OBD-II Connection ===========================

    if global_config["debug"]:
        obd.logger.setLevel(obd.logging.DEBUG)  # enables all debug information

    connection = obd.Async(global_config["port"], global_config["baud"])

    # if global_config["debug"]:
    #     for i in range(32):
    #         connection.supported_commands.append(obd.commands[1][i])

    # ============================ QT Application =============================

    app = QtGui.QApplication(sys.argv)
    pihud = PiHud(global_config, connection)

    # ============================== GPIO Setup ===============================

    try:
        pin = self.config.page_adv_pin
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GIO.add_event_detect(pin,
                             GPIO.FALLING,
                             callback=pihud.next_page,
                             bouncetime=200)
    except:
        pass

    # ================================= Start =================================

    status = app.exec_()  # blocks until application quit

    # ================================= Exit ==================================

    connection.close()
    sys.exit(status)
Exemple #14
0
    def run(self):
        self.gconfig = GlobalConfig.instance()
	self.znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	ip = self.gconfig.GetValue('CONFIG','sqlstore-ip')
	port = self.gconfig.GetValue('CONFIG','sqlstore-port')

	#run server for clients and game server
	nserver = net_server(self.znetlib)
	ns_arg = ns_arg_t()
	ns_arg.ip = ip
	ns_arg.port = port
	nserver.ns_start(ns_arg)

	client_manager = ClientManager(nserver)

	client_manager.Init()
	client_manager.run()
Exemple #15
0
    def Init(self):
        """
        """
        from ClientManager import ClientManager
	self.gconfig = GlobalConfig.instance()

        #start server
	znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	gsip = self.gconfig.GetValue('CONFIG','gs-server-address')
	gsport = self.gconfig.GetValue('CONFIG','gs-server-port')
	self.nserver = net_server(znetlib)
	ns_arg = ns_arg_t()
	ns_arg.ip = gsip
	ns_arg.port = gsport
	self.nserver.ns_start(ns_arg)

	self.client_manager = ClientManager.instance()
	return True
Exemple #16
0
    def Init(self):
        """
        """
        from ClientManager import ClientManager
        self.gconfig = GlobalConfig.instance()

        #start server
        znetlib = self.gconfig.GetValue('CONFIG', 'net-lib')
        gsip = self.gconfig.GetValue('CONFIG', 'gs-server-address')
        gsport = self.gconfig.GetValue('CONFIG', 'gs-server-port')
        self.nserver = net_server(znetlib)
        ns_arg = ns_arg_t()
        ns_arg.ip = gsip
        ns_arg.port = gsport
        self.nserver.ns_start(ns_arg)

        self.client_manager = ClientManager.instance()
        return True
Exemple #17
0
    def Init(self):
        """
        """
        from GSManager import GSManager
        self.gconfig = GlobalConfig.instance()

        #start server
        znetlib = self.gconfig.GetValue('CONFIG', 'net-lib')
        csip = self.gconfig.GetValue('CONFIG', 'clients-server-address')
        csport = self.gconfig.GetValue('CONFIG', 'clients-server-port')
        self.nserver = net_server(znetlib)
        ns_arg = ns_arg_t()
        ns_arg.ip = csip
        ns_arg.port = csport
        self.nserver.ns_start(ns_arg)

        self.playermanager = PlayerManager.instance()
        self.playermanager.Init()
        self.gsmanager = GSManager.instance()
        return True
Exemple #18
0
    def Init(self):
        """
        """
        from GSManager import GSManager
	self.gconfig = GlobalConfig.instance()

        #start server
	znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	csip = self.gconfig.GetValue('CONFIG','clients-server-address')
	csport = self.gconfig.GetValue('CONFIG','clients-server-port')
	self.nserver = net_server(znetlib)
	ns_arg = ns_arg_t()
	ns_arg.ip = csip
	ns_arg.port = csport
	self.nserver.ns_start(ns_arg)

	self.playermanager = PlayerManager.instance()
	self.playermanager.Init()
        self.gsmanager = GSManager.instance()
	return True
Exemple #19
0
    def Init(self):
        from GateLogic import GateLogic
        from scenemanager import SceneManager

        self.uuid = uuid.instance()

        self.gconfig = GlobalConfig.instance()
        znetlib = self.gconfig.GetValue('CONFIG', 'net-lib')
        sqlip = self.gconfig.GetValue('CONFIG', 'sqlstore-address')
        sqlport = self.gconfig.GetValue('CONFIG', 'sqlstore-port')
        #connect to sqlstore
        self.nclient = net_client(znetlib)
        nc_arg = nc_arg_t()
        nc_arg.ip = sqlip
        nc_arg.port = sqlport
        rv = self.nclient.nc_connect(nc_arg)
        if not rv:
            PutLogList("(*) Connect to sqlstore IP:%s PORT:%d failed!"\
             % (sqlip,sqlport))
            return False

        self.gatelogic = GateLogic.instance()
        self.scene_manager = SceneManager.instance()
        return True
Exemple #20
0
	def Init(self):
            from ClientManager import ClientManager
            from PlayerManager import PlayerManager
	    self.uuid = uuid.instance()

            self.gconfig = GlobalConfig.instance()
	    znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	    sqlip = self.gconfig.GetValue('CONFIG','sqlstore-address')
	    sqlport = self.gconfig.GetValue('CONFIG','sqlstore-port')
	    #connect to sqlstore
	    self.nclient = net_client(znetlib)
	    nc_arg = nc_arg_t()
	    nc_arg.ip = sqlip
	    nc_arg.port = sqlport
	    rv = self.nclient.nc_connect(nc_arg)
	    if not rv:
		PutLogList("(*) Connect to sqlstore IP:%s PORT:%d failed!"\
			% (sqlip,sqlport))
		return False

	    self.client_manager = ClientManager.instance()
	    self.player_manager = PlayerManager.instance()

	    return True
Exemple #21
0
	def Init(self):
	    from GateLogic import GateLogic
	    from scenemanager import SceneManager

	    self.uuid = uuid.instance()

            self.gconfig = GlobalConfig.instance()
	    znetlib = self.gconfig.GetValue('CONFIG','net-lib')
	    sqlip = self.gconfig.GetValue('CONFIG','sqlstore-address')
	    sqlport = self.gconfig.GetValue('CONFIG','sqlstore-port')
	    #connect to sqlstore
	    self.nclient = net_client(znetlib)
	    nc_arg = nc_arg_t()
	    nc_arg.ip = sqlip
	    nc_arg.port = sqlport
	    rv = self.nclient.nc_connect(nc_arg)
	    if not rv:
		PutLogList("(*) Connect to sqlstore IP:%s PORT:%d failed!"\
			% (sqlip,sqlport))
		return False

	    self.gatelogic = GateLogic.instance()
	    self.scene_manager = SceneManager.instance()
	    return True
    def __init__(self, d, a, pl):
        self.gconfig = GlobalConfig.instance()
        self.url = self.gconfig.GetValue('CONFIG','url')
        self.root = self.gconfig.GetValue('CONFIG','www-root')
        self.d = d
        self.a = a
        self.pl = pl
        self.flag = Event()
        frame = wxFrame(None, -1, 'BitTorrent make directory', size = wxSize(550, 250))
        self.frame = frame

        panel = wxPanel(frame, -1)

        gridSizer = wxFlexGridSizer(cols = 1, vgap = 15, hgap = 8)

        self.currentLabel = wxStaticText(panel, -1, 'checking file sizes')
        gridSizer.Add(self.currentLabel, 0, wxEXPAND)
        self.gauge = wxGauge(panel, -1, range = 1000, style = wxGA_SMOOTH)
        gridSizer.Add(self.gauge, 0, wxEXPAND)
        #gridSizer.Add(10, 10, 1, wxEXPAND)
        self.button = wxButton(panel, -1, 'cancel')
        gridSizer.Add(self.button, 0, wxALIGN_CENTER)
        gridSizer.AddGrowableRow(2)
        gridSizer.AddGrowableCol(0)

        g2 = wxFlexGridSizer(cols = 1, vgap = 15, hgap = 8)
        g2.Add(gridSizer, 1, wxEXPAND | wxALL, 25)
        g2.AddGrowableRow(0)
        g2.AddGrowableCol(0)
        panel.SetSizer(g2)
        panel.SetAutoLayout(True)
        EVT_BUTTON(frame, self.button.GetId(), self.done)
        EVT_CLOSE(frame, self.done)
        EVT_INVOKE(frame, self.onInvoke)
        frame.Show(True)
        Thread(target = self.complete).start()
Exemple #23
0
            if inputID not in inputs:
                continue
            pointInfo = inputs[inputID]
            if (pointInfo and pointInfo['point_id']):
                logBlock[pointInfo["point_id"]] = {"value": dataArray[x]}
        return logBlock

    def calcInputID(self, pos):
        controller = self.controller
        inputID = ''
        if (pos <= controller['NUM_OF_AI']):
            inputID = "AI_" + str(pos)
        elif (pos <= (controller['NUM_OF_AI'] + controller['NUM_OF_DI'])):
            inputID = "DI_" + str(pos - controller['NUM_OF_AI'])
        else:
            inputID = "CUST_" + str(pos - (
                (controller['NUM_OF_AI'] + controller['NUM_OF_DI'])))
        return inputID


if __name__ == '__main__':
    testController = GlobalConfig().getControllers()[0]
    testHandler = ModbusHandler(testController)
    testData = [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1,
        1, 7.5, 3.4, 23.42, 23, 0
    ]
    testLogBlock = testHandler.getLogBlock(testData)
    print('Test Log Block: ')
    print(testLogBlock)
Exemple #24
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import time
import os
import os.path
import re
from datetime import datetime
from LoggingManager import LoggingManager
from GlobalConfig import GlobalConfig

__author__ = 'urKh'

app_logger = LoggingManager('05.PolicyConfig')
config_vars = GlobalConfig.read_vars('05.PolicyConfig')

input_policies_l_details = config_vars.get('policies_l_details_file')
input_policies_u_details = config_vars.get('policies_u_details_file')
output_policy_config_csv = config_vars.get('output_policy_config_csv')


class PolicyConfig(object):

    tmp_pd = []
    tmp_policyu = []

    def process_policy_u(self):

        policy = None
        policy_type = None
        active = None
        backup = None
Exemple #25
0
import Elevator
import Servo
import GlobalGPIO
import Gripper
from time import sleep
import LPTenderMock
from LPTenderStateMachine import States
from LPTenderStateMachine import LpTenderStateMachine
from LPTenderStateMachine import Transitions

from GlobalConfig import GlobalConfig

if __name__ == "__main__":

    config = GlobalConfig()

    with GlobalGPIO.GlobalGPIO() as gpio:
        gripper = Gripper.Gripper(gpio, config)
        gripper.release()
        # sleep(2)
        #   gripper.grip()
        #   sleep(2)
        #    gripper.release()

        elevator = Elevator.Elevator(config, gpio)

        elevator.gotoHome()

        HOME_TO_BASE = 100000
        FLIPPED_DELTA = 18000
Exemple #26
0
 def __init__(self):
     self.config = GlobalConfig()
     self.master = modbus_tcp.TcpMaster(
         host=self.config.getModbusInfo('MODBUS_ADDRESS'), port=502)
Exemple #27
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import time
import os
import os.path
from datetime import datetime
from LoggingManager import LoggingManager
from GlobalConfig import GlobalConfig

__author__ = 'urKh'

app_logger = LoggingManager('03.ExtractInfo')
config_vars = GlobalConfig.read_vars('03.ExtractInfo')

input_bpdbjobs_file = config_vars.get('bpdbjobs_file')
input_bpimagelist_file = config_vars.get('bpimagelist_file')
#input_allpolicies_file = config_vars.get('allpolicies_file')
input_policies_l_details_file = config_vars.get('policies_l_details_file')
output_extracted_info = config_vars.get('output_extracted_info')


class ExtractInfo(object):

    tmp_pd = []

    def write_scheds(self, tmp_policy_client, scheds):
        for polcli in tmp_policy_client:
            self.tmp_pd.append([polcli])
            self.tmp_pd[-1].append(None)
            self.tmp_pd[-1].append(None)
Exemple #28
0
 def __init__(self, controller):
     self.config = GlobalConfig()
     self.envVars = self.config.getEnvVars()
     if (controller):
         self.controller = controller
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import time
import os
import os.path
from datetime import datetime
from LoggingManager import LoggingManager
from GlobalConfig import GlobalConfig

__author__ = 'urKh'

app_logger = LoggingManager('04.AllSequences')
config_vars = GlobalConfig.read_vars('04.AllSequences')

input_policies_l_details = config_vars.get('policies_l_details_file')
output_allseq = config_vars.get('output_allseq_file')


class AllSequences(object):

    tmp_pd = []

    def process_polcli(self, tmp_policy_client):
        for polcli in tmp_policy_client:
            #import ipdb; ipdb.set_trace()
            self.tmp_pd.append([polcli])

    def process_data(self):
        new_class = False
        policy_name = None
        client = None
Exemple #30
0
 def __init__(self):
     self.config = GlobalConfig()
     self.ModbusDevice = ModbusHandler()
    def __init__(self, index=None, maNum=None, doOutPut=True):
        super(CaseManager, self).__init__()
        GlobalConfig().set('mode', 'Smaug')
        if index == None:
            # index = 'SZ159915' # 创业板ETF
            # index = 'SH510300' # 300ETF
            # index = 'SH510050' # 50ETF
            # index = 'SZ159902' # 中小板
            # index = 'SZ159901' # 深100ETF
            # index = 'SZ150153' # 创业板分级B
            # index = 'SH600036' # 招商银行
            # index = 'SH600196' # 复星医药
            # index = 'SH600519' # 贵州茅台
            # index = 'SH600547' # 山东黄金
            # index = 'SH000016' #上证50
            # index = 'SZ399006' # 创业板指
            # index = 'SZ399976' # CS新能车
            # index = 'SZ399997' # 中证白酒
            # index = 'SZ399975' # 证券公司
            # index = 'SZ399707' # CSSW证券
            index = 'SH000300'  # 沪深300
        atrKey = '20'
        mmax = ['10']
        mmin = ['20']
        # ma = ['5', '10', '20', '40', '60']
        ma = ['5', '20']
        self.beginAsset = 10000000

        if maNum == None:
            maNum = 20

        if not str(maNum) in ma:
            ma.append(str(maNum))

        # action = {
        # 	'buy':B2(maNum), # 均线突破开仓,N倍ATR加仓
        # 	'sell':S2(maNum), # 向下突破均线清仓
        # 	'asset':Elephant(tax = 0), # 莽撞法
        # 	'stock':Stock(atr = [atrKey], max = mmax, min = mmin, ma = ma, index = index)
        # }

        # action = {
        # 	'buy':B8(maNum), # 下跌补仓
        # 	'sell':S8(maNum), # 均线上卖出
        # 	'asset':Segment(totalCount = 5, tax = 0), # 分段
        # 	'stock':Stock(atr = [atrKey], max = mmax, min = mmin, ma = ma, index = index)
        # }

        # action = {
        # 	'buy':B9(), # 加权均线突破买入
        # 	'sell':S9(), # 加权均线突破卖出
        # 	'asset':Elephant(tax = 0), # 莽撞法
        # 	'stock':Stock(atr = [atrKey], max = mmax, min = mmin, ma = ma, index = index)
        # }

        action = {
            'buy': B2(maNum),  # 均线突破开仓,N倍ATR加仓
            'sell': S2(maNum),  # 向下突破均线清仓
            'asset': Segment(totalCount=5, tax=0),  # 分段
            'stock': Stock(atr=[atrKey],
                           max=mmax,
                           min=mmin,
                           ma=ma,
                           index=index)
        }

        # assets = [
        # 	# Turtle(atrKey = atrKey, tax = 0), # 海龟法
        # 	# Elephant(tax = 0), # 莽撞法
        # 	Segment(totalCount = 5, tax = 0) # 分段
        # ]

        # buys = [
        # 	# B1(), #最大值突破开仓,N倍ATR加仓
        # 	# B2(maNum), #均线突破开仓,N倍ATR加仓
        # 	# B3(maNum, 60), #带震荡屏蔽掉均线突破
        # 	# B4(), # 突破均价则买入,但是根据波动率自动调整均线
        # 	# B5(maNum), # 有保底的均线突破买入
        # 	# B6(std = '20', ma = '20', stdTimes = 2), # 均值回归
        # 	# B7('5', '20'), # 双线法买入
        # 	B8(maNum), #下跌补仓
        # ]

        # sells = [
        # 	# S1(), #向下突破ATR清仓
        # 	# S2(maNum), #向下突破均线清仓
        # 	# S3(ma = 20, atrKey = '20', atrTimes = 2) # 开仓位跌到ATR时清仓;开仓位之上跌破均线清仓
        # 	# S4(ma = 20, atrKey = '20', atrTimes = 2) # 开仓位跌到ATR或跌破均线清仓
        # 	# S5(maNum), # 有保底的均线突破卖出
        # 	# S6(ma = '20'), # 均值回归
        # 	# S7('5', '20') # 双线法卖出
        # 	S8(maNum), #均线上卖出
        # ]

        # stocks = [
        # 	Stock(atr = [atrKey], max = mmax, min = mmin, ma = ma, index = index)
        # ]

        self.asset = action['asset']
        self.buy = action['buy']
        self.sell = action['sell']
        self.stock = action['stock']

        self.doOutPut = doOutPut
        self.mode = 0  # 改模式

        self.isSave = False  #不输出
Exemple #32
0
    def __init__(self, nserver):
	self.nserver = nserver
	self.gconfig = GlobalConfig.instance()
Exemple #33
0
 def __init__(self):
     super(Tips, self).__init__()
     GlobalConfig().set('mode', 'Hobbit')
Exemple #34
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import time
import sys
import os
import os.path
from datetime import datetime
from LoggingManager import LoggingManager
from GlobalConfig import GlobalConfig

__author__ = 'urKh'

app_logger = LoggingManager('20.CompareFiles')
config_vars = GlobalConfig.read_vars('20.CompareFiles')

input_allseq_file = config_vars.get('input_allseq_file')
input_historyallsorted_file = config_vars.get('input_historyallsorted_file')
output_nopolicy_file = config_vars.get('output_nopolicy_file')


class CompareFiles:

    def process_data(self):
        temp_historyall = []
        temp_allseq = []

        allseq_file = open(input_allseq_file, 'r').readlines()
        historyallsorted_file = open(input_historyallsorted_file, 'r').readlines()

        [temp_historyall.append(row.split(',')[0].strip() + ', ' + row.split(',')[1].strip()) for row in historyallsorted_file]
        [temp_allseq.append(row.split(',')[0].strip() + ', ' + row.split(',')[1].strip()) for row in allseq_file]
Exemple #35
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'Codengine'

import time
from datetime import datetime
import os
from LoggingManager import LoggingManager
from GlobalConfig import GlobalConfig

config_vars = GlobalConfig.read_vars('19.MainIndex')

default_page_title = config_vars.get('default_page_title')
#dashboard_files_dir = config_vars.get('dashboard_files_dir')
default_html_output_file_path = config_vars.get(
    'default_html_output_file_path')
timetorun_file = config_vars.get('timetorun_file')

app_logger = LoggingManager('19.MainIndex.py')

# Policy Type
dashboard_policy_type = config_vars.get('dashboard_policy_type')

# Billing
dashboard_billing_file = config_vars.get('dashboard_billing_file')

# Open Actions
dashboard_liveview_file = config_vars.get('dashboard_liveview_file')
dashboard_historyview_file = config_vars.get('dashboard_historyview_file')
dashboard_monthly_view_file = config_vars.get('dashboard_monthly_view_file')
Exemple #36
0
 def __init__(self):
   config =  GlobalConfig()
   self.envVars = config.getEnvVars()
   self.controllers = config.getControllers()
   self.ModbusHandler = ModbusHandler(None)