Browse Source

增加di、do、ai、ao路数,

一只小菜杨 2 months ago
parent
commit
d632af5834
2 changed files with 64 additions and 78 deletions
  1. 21 3
      src/views/CommandInfo.vue
  2. 43 75
      src/views/ProjectInfo.vue

+ 21 - 3
src/views/CommandInfo.vue

@@ -207,16 +207,34 @@ const currentTime = ref(['00', '00'])
 const pickerType = ref('')
 const columnsMap: Record<string, any> = {
   inputLabel: [
+    { text: 'DI0', value: 'DI0' },
     { text: 'DI1', value: 'DI1' },
     { text: 'DI2', value: 'DI2' },
+    { text: 'DI3', value: 'DI3' },
+    { text: 'DI4', value: 'DI4' },
+    { text: 'DI5', value: 'DI5' },
+    { text: 'DI6', value: 'DI6' },
+    { text: 'DI7', value: 'DI7' },
+    { text: 'DI8', value: 'DI8' },
+    { text: 'DI9', value: 'DI9' },
+    { text: 'AI0', value: 'AI0' },
     { text: 'AI1', value: 'AI1' },
-    { text: 'AI2', value: 'AI2' }
+    { text: 'AI2', value: 'AI2' },
+    { text: 'AI3', value: 'AI3' }
   ],
   outputLabel: [
+    { text: 'DO0', value: 'DO0' },
     { text: 'DO1', value: 'DO1' },
     { text: 'DO2', value: 'DO2' },
-    { text: 'AO1', value: 'AO1' },
-    { text: 'AO2', value: 'AO2' }
+    { text: 'DO3', value: 'DO3' },
+    { text: 'DO4', value: 'DO4' },
+    { text: 'DO5', value: 'DO5' },
+    { text: 'DO6', value: 'DO6' },
+    { text: 'DO7', value: 'DO7' },
+    { text: 'DO8', value: 'DO8' },
+    { text: 'DO9', value: 'DO9' },
+    { text: 'AO0', value: 'AO0' },
+    { text: 'AO1', value: 'AO1' }
   ],
   commandValue: [
     { text: '闭合', value: '闭合' },

+ 43 - 75
src/views/ProjectInfo.vue

@@ -205,35 +205,50 @@ const getXMLFile = () => {
     周日: 3
   }
 
+  const globalVarList = [
+    'DI0',
+    'DI1',
+    'DI2',
+    'DI3',
+    'DI4',
+    'DI5',
+    'DI6',
+    'DI7',
+    'DI8',
+    'DI9',
+    'AI0',
+    'AI1',
+    'AI2',
+    'AI3',
+    'DO0',
+    'DO1',
+    'DO2',
+    'DO3',
+    'DO4',
+    'DO5',
+    'DO6',
+    'DO7',
+    'DO8',
+    'DO9',
+    'AO0',
+    'AO1'
+  ]
+
   let instanceXml = ''
+  let globalVarsXml = ''
+  globalVarList.forEach((item) => {
+    globalVarsXml += `<variable name="${item}">
+                        <type><${item.includes('A') ? 'INT' : 'BOOL'} /></type>
+                      </variable>`
+  })
   crtProject.value.commandList.forEach((item, index) => {
     instanceXml += `<pouInstance name="instance${index}" typeName="program${index}"/>`
     xml += `<pou name="program${index}" pouType="program">
               <interface>
                 <externalVars>
-                  <variable name="DI1">
-                      <type><BOOL /></type>
-                    </variable>
-                    <variable name="DI2">
-                      <type><BOOL /></type>
-                    </variable>
-                    <variable name="AI1">
-                      <type><INT /></type>
-                    </variable>
-                    <variable name="AI2">
-                      <type><INT /></type>
-                    </variable>
-                    <variable name="DO1">
-                      <type><BOOL /></type>
-                    </variable>
-                    <variable name="DO2">
-                      <type><BOOL /></type>
-                    </variable>
-                    <variable name="AO1">
-                      <type><INT /></type>
-                    </variable>
-                    <variable name="AO2">
-                      <type><INT /></type>
+                ${globalVarsXml}
+                    <variable name="CRT_DATA">
+                      <type><DT /></type>
                     </variable>
                 </externalVars>
                 <localVars>
@@ -267,12 +282,6 @@ const getXMLFile = () => {
                       <simpleValue value="60" />
                     </initialValue>
                   </variable>
-                  <variable name="CRT_DATA">
-                    <type><DT /></type>
-                    <initialValue>
-                      <simpleValue value="DT#${formatDateTime(new Date(), '-')}" />
-                    </initialValue>
-                  </variable>
                   <variable name="MUL_NUM">
                     <type><INT /></type>
                     <initialValue>
@@ -357,7 +366,7 @@ const getXMLFile = () => {
                         <simpleValue value="${cItem.value}" />
                       </initialValue>
                     </variable>`
-          } else if (cItem.type === 'input' && cItem.label.includes('AO')) {
+          } else if (cItem.type === 'output' && cItem.label.includes('AO')) {
             // 赋值AO变量
             xml += `<variable name="SET_AI${index}_${cIndex}">
                       <type><INT /></type>
@@ -1334,52 +1343,11 @@ const getXMLFile = () => {
               </task>
             </resource>
             <globalVars>
-              <variable name="DI1">
-                <type><BOOL /></type>
-                <initialValue>
-                  <simpleValue value="false" />
-                </initialValue>
-              </variable>
-              <variable name="DI2">
-                <type><BOOL /></type>
-                <initialValue>
-                  <simpleValue value="false" />
-                </initialValue>
-              </variable>
-              <variable name="AI1">
-                <type><INT /></type>
-                <initialValue>
-                  <simpleValue value="4" />
-                </initialValue>
-              </variable>
-              <variable name="AI2">
-                <type><INT /></type>
-                <initialValue>
-                  <simpleValue value="4" />
-                </initialValue>
-              </variable>
-              <variable name="DO1">
-                <type><BOOL /></type>
-                <initialValue>
-                  <simpleValue value="false" />
-                </initialValue>
-              </variable>
-              <variable name="DO2">
-                <type><BOOL /></type>
-                <initialValue>
-                  <simpleValue value="false" />
-                </initialValue>
-              </variable>
-              <variable name="AO1">
-                <type><INT /></type>
-                <initialValue>
-                  <simpleValue value="2" />
-                </initialValue>
-              </variable>
-              <variable name="AO2">
-                <type><INT /></type>
+              ${globalVarsXml}
+              <variable name="CRT_DATA">
+                <type><DT /></type>
                 <initialValue>
-                  <simpleValue value="2" />
+                  <simpleValue value="DT#${formatDateTime(new Date(), '-')}" />
                 </initialValue>
               </variable>
             </globalVars>