Subversion Repositories HomeAutomation

Rev

Rev 1572 | Rev 1727 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1572 Rev 1574
Line 46... Line 46...
46
def getModuleIdsFromFile(moduleName):
46
def getModuleIdsFromFile(moduleName):
47
	takenIds = []
47
	takenIds = []
48
	for applicationName in os.listdir("../"):	
48
	for applicationName in os.listdir("../"):	
49
		if applicationName[0] != '.' and os.path.exists("../" + applicationName + "/config.inc"):
49
		if applicationName[0] != '.' and os.path.exists("../" + applicationName + "/config.inc"):
50
			takenIds = parseModuleIdFromFile(moduleName, "../" + applicationName + "/config.inc")
50
			takenIds = parseModuleIdFromFile(moduleName, "../" + applicationName + "/config.inc")
-
 
51
 
51
	return takenIds
52
	return takenIds
52
	
53
	
53
 
54
 
54
def getFreeModuleId(takenIds):
55
def getFreeModuleId(takenIds):
55
	if len(takenIds) == 0:
56
	if len(takenIds) == 0:
56
		return 1
57
		return 1
57
	takenIds.sort()
58
	takenIds.sort()
58
 
59
 
59
	lastId = 0
60
	lastId = 0
60
 
61
 
61
	for takenId in takenIds:
62
	for takenId in takenIds:
62
		if takenId != lastId+1:
63
		if takenId != lastId+1:
63
			return lastId+1
64
			return lastId+1
64
		lastId = takenId
65
		lastId = takenId
65
 
66
 
66
	return lastId+1
67
	return lastId+1
67
 
68
 
68
 
69
 
69
 
70
 
70
def compileMainFile():
71
def compileMainFile():
71
	print "Compiling new main.c..."
72
	print "Compiling new main.c..."
72
	main_c_template = open('src/main.c.template', 'r') 
73
	main_c_template = open('src/main.c.template', 'r') 
73
	main_c_template_lines = main_c_template.readlines()
74
	main_c_template_lines = main_c_template.readlines()
74
	main_c_template.close()
75
	main_c_template.close()
75
	
76
	
76
	modules = getLocalModules()
77
	modules = getLocalModules()
77
	
78
	
78
	main_c = open('src/main.c', 'w') 
79
	main_c = open('src/main.c', 'w') 
79
	
80
	
80
	for main_c_template_line in main_c_template_lines:
81
	for main_c_template_line in main_c_template_lines:
81
		pos_include = main_c_template_line.find('%INCLUDE')
82
		pos_include = main_c_template_line.find('%INCLUDE')
Line 125... Line 126...
125
		else:
126
		else:
126
			if line.find("## End section " + sectionName) != -1:
127
			if line.find("## End section " + sectionName) != -1:
127
				inSection = False
128
				inSection = False
128
				
129
				
129
			sectionLines.append(line.strip("\n"))
130
			sectionLines.append(line.strip("\n"))
130
			
131
			
131
	return sectionLines
132
	return sectionLines
132
	
133
	
133
 
134
 
134
def updateConfigFile():
135
def updateConfigFile():
135
	print "Updating config.inc..."
136
	print "Updating config.inc..."
136
	modules = getLocalModules()
137
	modules = getLocalModules()
137
	moduleSections = {}
138
	moduleSections = {}
138
	applicationSection = []
139
	applicationSection = []
139
	
140
	moduleName="none"
140
	if not os.path.exists("config.inc"):
141
	if not os.path.exists("config.inc"):
141
		applicationSection = readConfigSection("src/config.inc.template", "application")
142
		applicationSection = readConfigSection("src/config.inc.template", "application")
142
		
143
		
143
		for moduleName in modules:
144
		for moduleName in modules:
144
			moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
145
			moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
145
	else:
146
	else:
146
		applicationSection = readConfigSection("config.inc", "application")
147
		applicationSection = readConfigSection("config.inc", "application")
147
		
148
		
148
		for moduleName in modules:
149
		for moduleName in modules:
149
			moduleSections[moduleName] = readConfigSection("config.inc", moduleName)
150
			moduleSections[moduleName] = readConfigSection("config.inc", moduleName)
150
			
151
			
151
			if len(moduleSections[moduleName]) <= 1:
152
			if len(moduleSections[moduleName]) <= 1:
152
				moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
153
				moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
153
	
154
	
154
	timers = 0
155
	timers = 0
155
	pcints = 0
156
	pcints = 0
156
	
157
	
157
	moduleIds = getModuleIdsFromFile(moduleName)
158
	moduleIds = getModuleIdsFromFile(moduleName)
158
	
-
 
159
	
159
	
160
	for moduleName, moduleSection in moduleSections.iteritems():
160
	for moduleName, moduleSection in moduleSections.iteritems():
161
		c = 0
161
		c = 0
162
		for line in moduleSection:
162
		for line in moduleSection:
163
			if len(line) > 0:
163
			if len(line) > 0: