# HG changeset patch # User etisserant # Date 1190044839 -7200 # Node ID 1f5407c0263f8512ca05e5df22fa2b4541dfa14e # Parent 937640beb46441cdf220b2825888e6de4c5bb71b Various changes to make SVGUI plugin generated code eventually compile diff -r 937640beb464 -r 1f5407c0263f plugins/svgui/svgui.py --- a/plugins/svgui/svgui.py Mon Sep 17 17:45:15 2007 +0200 +++ b/plugins/svgui/svgui.py Mon Sep 17 18:00:39 2007 +0200 @@ -88,7 +88,7 @@ "STRING" : "B", "BYTE" : "B", "WORD" : "W", "DWORD" : "D", "LWORD" : "L", "WSTRING" : "W"} """ TYPECONVERSION = {"BOOL" : "X", "UINT" : "W","REAL" : "D","STRING" : "B"} -CTYPECONVERSION = {"BOOL" : "bool", "UINT" : "unsigned int", "STRING" : "char*", "REAL" : "float"} +CTYPECONVERSION = {"BOOL" : "IEC_BOOL", "UINT" : "IEC_UINT", "STRING" : "IEC_STRING", "REAL" : "IEC_REAL"} CPRINTTYPECONVERSION = {"BOOL" : "d", "UINT" : "d", "STRING" : "s", "REAL" : "f"} class RootClass(DEFControler): @@ -128,10 +128,10 @@ def GenerateProgramHeadersPublicVars(self): fct = "" fct += " void OnPlcOutEvent(wxEvent& event);\n\n" - fct += " void IN_"+self.BusNumber+"();\n" - fct += " void OUT_"+self.BusNumber+"();\n" + fct += " void Retrive();\n" + fct += " void Publish();\n" fct += " void Initialize();\n" - fct += " void Print();\n" +# fct += " void Print();\n" return fct def GenerateIECVars(self): @@ -174,7 +174,7 @@ return text def GenerateGlobalVarsAndFuncs(self): - text = "" + text = "#include \"iec_types.h\"\n\n" pri_vars = self.GenerateIECVars() if (pri_vars): text += pri_vars @@ -241,6 +241,16 @@ text += " myapp->Publish()" text += " }" text += "}\n\n" + + text += "IEC_STRING wxStringToIEC_STRING(wxString s)\n" + text += "{\n" + text += " STRING res = {0,""};\n" + text += " for(int i=0; iGetValue());\n" + fct += " _copy__IB"+self.BusNumber+"_"+element_id+"_1 = wxStringToIEC_STRING(text->GetValue());\n" fct += " _copy__IX"+self.BusNumber+"_"+element_id+"_2 = true;\n" fct += _unlock fct += " }\n" @@ -676,7 +686,7 @@ if (not textctrl): fct += " SVGUITextCtrl* text;\n" fct += " text = (SVGUITextCtrl*)GetElementById(wxT(\""+element_id+"\"));\n" - fct += " _copy__IB"+self.BusNumber+"_"+element_id+"_1 = wxStringToStr(text->GetValue());\n" + fct += " _copy__IB"+self.BusNumber+"_"+element_id+"_1 = wxStringToIEC_STRING(text->GetValue());\n" fct += " _copy__IX"+self.BusNumber+"_"+element_id+"_2 = true;\n\n" textctrl = True elif type == "ScrollBar": @@ -714,30 +724,30 @@ fct += "}\n\n" #DEBUG Fonction d'affichage - fct += "void Program::Print()\n{\n" - for element in elementsTab: - infos = element.getElementAttributes() - for info in infos: - if info["name"] == "id": - element_id = str(info["value"]) - type = element.GetElementInfos()["type"] - FbdBlock = self.GetBlockType(type) - element_num_patte = 1 - for input in FbdBlock["inputs"]: - element_type = TYPECONVERSION[input[1]] - c_type = CPRINTTYPECONVERSION[input[1]] - var = "_copy__Q"+element_type+self.BusNumber+"_"+element_id+"_"+str(element_num_patte) - fct +=" printf(\""+var+": %"+c_type+"\\n\","+var+");\n" - element_num_patte +=1 - element_num_patte = 1 - for output in FbdBlock["outputs"]: - element_type = TYPECONVERSION[output[1]] - c_type = CPRINTTYPECONVERSION[output[1]] - var = "_copy__I"+element_type+self.BusNumber+"_"+element_id+"_"+str(element_num_patte) - fct +=" printf(\""+var+": %"+c_type+"\\n\","+var+");\n" - element_num_patte +=1 +# fct += "void Program::Print()\n{\n" +# for element in elementsTab: +# infos = element.getElementAttributes() +# for info in infos: +# if info["name"] == "id": +# element_id = str(info["value"]) +# type = element.GetElementInfos()["type"] +# FbdBlock = self.GetBlockType(type) +# element_num_patte = 1 +# for input in FbdBlock["inputs"]: +# element_type = TYPECONVERSION[input[1]] +# c_type = CPRINTTYPECONVERSION[input[1]] +# var = "_copy__Q"+element_type+self.BusNumber+"_"+element_id+"_"+str(element_num_patte) +# fct +=" printf(\""+var+": %"+c_type+"\\n\","+var+");\n" +# element_num_patte +=1 +# element_num_patte = 1 +# for output in FbdBlock["outputs"]: +# element_type = TYPECONVERSION[output[1]] +# c_type = CPRINTTYPECONVERSION[output[1]] +# var = "_copy__I"+element_type+self.BusNumber+"_"+element_id+"_"+str(element_num_patte) +# fct +=" printf(\""+var+": %"+c_type+"\\n\","+var+");\n" +# element_num_patte +=1 #fct +=" wxPostEvent(Program,wxEVT_PLCOUT);\n" - fct +="};\n\n" +# fct +="};\n\n" return fct def PlugGenerate_C(self, buildpath, locations, logger):