| 1 | /* |
| 2 | * File: UtilityRunner.cpp |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "UtilityRunner.h"cxx . . $ `<file>/HercUtilities/UtilityRunner.h`/ |
| 26 | #include "HerculesStudio.h"cxx . . $ `<file>/HercStudio/HerculesStudio.h`/ |
| 27 | #include "UtilityExecutor.h"cxx . . $ `<file>/HercUtilities/UtilityExecutor.h`/ |
| 28 | #include "StringTokenizer.h"cxx . . $ `<file>/HercStudio/StringTokenizer.h`/ |
| 29 | #include "ConfigurationEditor.h"cxx . . $ `<file>/HercConfiguration/ConfigurationEditor.h`/ |
| 30 | |
| 31 | #include <QProcess> |
| 32 | |
| 33 | #include <sstream> |
| 34 | #include <cerrno> |
| 35 | #include <cstdio> |
| 36 | |
| 37 | UtilityRunnercxx . . $ UtilityRunner#::UtilityRunnercxx . . $ UtilityRunner#UtilityRunner(fe7997c7923ebae2).(UtilityExecutorcxx . . $ UtilityExecutor# * utilityExecutor) |
| 38 | : mUtilityExecutorcxx . . $ UtilityRunner#mUtilityExecutor.(utilityExecutor), mProcesscxx . . $ UtilityRunner#mProcess.(utilityExecutor->getQProcesscxx . . $ UtilityExecutor#getQProcess(54dfb229bc559d84).()) |
| 39 | { |
| 40 | |
| 41 | } |
| 42 | |
| 43 | UtilityRunnercxx . . $ UtilityRunner#::~cxx . . $ UtilityRunner#`~UtilityRunner`(49f6e7a06ebc5aa8).UtilityRunnercxx . . $ UtilityRunner#() |
| 44 | { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | void UtilityRunnercxx . . $ UtilityRunner#::runcxx . . $ UtilityRunner#run(49f6e7a06ebc5aa8).() |
| 49 | { |
| 50 | //mUtilityExecutor->getQProcess()->waitForStarted(); |
| 51 | mProcesscxx . . $ UtilityRunner#mProcess. = mUtilityExecutorcxx . . $ UtilityRunner#mUtilityExecutor.->getQProcesscxx . . $ UtilityExecutor#getQProcess(54dfb229bc559d84).(); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | void UtilityRunnercxx . . $ UtilityRunner#::updateStatuscxx . . $ UtilityRunner#updateStatus(9c546c94e5fcce4e).(const stdcxx . . $ std/::stringcxx . . $ std/string#& line) |
| 56 | { |
| 57 | Tokenizercxx . . $ Tokenizer/::handlecxx . . $ Tokenizer/handle# pos, lastPos; |
| 58 | stdcxx . . $ std/::stringcxx . . $ std/string# word = StringTokenizercxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).::getFirstWordcxx . . $ StringTokenizer#getFirstWord(d6887f0d22b52f3).(line, pos, lastPos, " \t\n"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 59 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(1,"util runner line:" << line); |
| 60 | if (line.lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).() == 0) |
| 61 | return; |
| 62 | |
| 63 | if (word ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "HHCDU044I") // dasdinit |
| 64 | { |
| 65 | QByteArraycxx . . $ QByteArray# qlinecxx . . $ QByteArray#QByteArray(34d26762b42c433a).(line.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 66 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! errorcxx . . $ UtilityRunner#error(ddc4016aa177531b).(qlinecxx . . $ QByteArray#QByteArray(45672f3c6961a244).); |
| 67 | int i = line.findcxx . . $ std/__cxx11/basic_string#find(91d5177563f5ce1b).(":") + 2; |
| 68 | int cyls = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(i),10); |
| 69 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! maximumChangedcxx . . $ UtilityRunner#maximumChanged(d4f767463ce0a6b3).(cyls); |
| 70 | return; |
| 71 | } |
| 72 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"NMEM=") == 0) // dasdisup |
| 73 | { |
| 74 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 75 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! maximumChangedcxx . . $ UtilityRunner#maximumChanged(d4f767463ce0a6b3).(currMem); |
| 76 | return; |
| 77 | } |
| 78 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,4,"POS=") == 0) // dasdcopy |
| 79 | { |
| 80 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 81 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 82 | return; |
| 83 | } |
| 84 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"IPOS=") == 0) // hetmap |
| 85 | { |
| 86 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 87 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 88 | return; |
| 89 | } |
| 90 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,4,"MEM=") == 0) // dasdisup |
| 91 | { |
| 92 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 93 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 94 | return; |
| 95 | } |
| 96 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"ETRK=") == 0) // dasdls, dasdcat |
| 97 | { |
| 98 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 99 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! maximumChangedcxx . . $ UtilityRunner#maximumChanged(d4f767463ce0a6b3).(currMem); |
| 100 | return; |
| 101 | } |
| 102 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,4,"TRK=") == 0) // dasdcopy |
| 103 | { |
| 104 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(4),10); |
| 105 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 106 | return; |
| 107 | } |
| 108 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"CYLS=") == 0) // dasdconv |
| 109 | { |
| 110 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 111 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! maximumChangedcxx . . $ UtilityRunner#maximumChanged(d4f767463ce0a6b3).(currMem); |
| 112 | return; |
| 113 | } |
| 114 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,4,"CYL=") == 0) // dasdinit |
| 115 | { |
| 116 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(4),10); |
| 117 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 118 | return; |
| 119 | } |
| 120 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,4,"BLK=") == 0) // dasdinit |
| 121 | { |
| 122 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(4),10); |
| 123 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 124 | return; |
| 125 | } |
| 126 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"TRKS=") == 0) // dasdcopy |
| 127 | { |
| 128 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 129 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! maximumChangedcxx . . $ UtilityRunner#maximumChanged(d4f767463ce0a6b3).(currMem); |
| 130 | return; |
| 131 | } |
| 132 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"CTRK=") == 0) // dasdls, dasdcat |
| 133 | { |
| 134 | int currMem = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(5),10); |
| 135 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currMem); |
| 136 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(2,"Value changed " << currMem); |
| 137 | return; |
| 138 | } |
| 139 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,7,"OUTCYL=") == 0) |
| 140 | { |
| 141 | int currCyl = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(7),10); |
| 142 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currCyl); |
| 143 | return; |
| 144 | } |
| 145 | if (line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(0,5,"SIZE=") == 0) // dasdcopy |
| 146 | { |
| 147 | // swallow this message |
| 148 | return; |
| 149 | } |
| 150 | if (line.lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).() > 5 && line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(2,4,"CYL=") == 0) |
| 151 | { |
| 152 | int currCyl = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(4),10); |
| 153 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5, "emitting value changed to " << currCyl); |
| 154 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currCyl); |
| 155 | return; |
| 156 | } |
| 157 | if (line.lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).() > 2 && line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(2,8,"REQCYLS=") == 0) |
| 158 | { |
| 159 | int currCyl = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(8),10); |
| 160 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currCyl); |
| 161 | return; |
| 162 | } |
| 163 | if (line.lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).() > 2 && line.comparecxx . . $ std/__cxx11/basic_string#compare(42b39d70d030e8aa).(2,4,"BLK=") == 0) |
| 164 | { |
| 165 | int currCyl = ConfigurationEditorcxx . . $ ConfigurationEditor#::parseNumcxx . . $ ConfigurationEditor#parseNum(7b1020165ab78f0a).(line.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(4),10); |
| 166 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! valueChangedcxx . . $ UtilityRunner#valueChanged(d4f767463ce0a6b3).(currCyl); |
| 167 | return; |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | QByteArraycxx . . $ QByteArray# qlinecxx . . $ QByteArray#QByteArray(34d26762b42c433a).(line.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 172 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! errorcxx . . $ UtilityRunner#error(ddc4016aa177531b).(qlinecxx . . $ QByteArray#QByteArray(45672f3c6961a244).); |
| 173 | } |
| 174 | } |
| 175 | void UtilityRunnercxx . . $ UtilityRunner#::readStandardOutputcxx . . $ UtilityRunner#readStandardOutput(49f6e7a06ebc5aa8).() |
| 176 | { |
| 177 | if (mProcesscxx . . $ UtilityRunner#mProcess. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) return; |
| 178 | mProcesscxx . . $ UtilityRunner#mProcess.->setReadChannelcxx . . $ QProcess#setReadChannel(bf19820e89ffcdec).(QProcesscxx . . $ QProcess#::StandardOutputcxx . . $ QProcess#StandardOutput.); |
| 179 | while (true) |
| 180 | { |
| 181 | QByteArraycxx . . $ QByteArray# output = mProcesscxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).->readLinecxx . . $ QIODevice#readLine(1117a85f2fd4e5c8).(); |
| 182 | if (output.lengthcxx . . $ QByteArray#length(455f465bc33b4cdf).() == 0) break; |
| 183 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(2,"util runner:" << output.data()); |
| 184 | updateStatuscxx . . $ UtilityRunner#updateStatus(9c546c94e5fcce4e).(QStringcxx . . $ QString#QString(45672f3c6961a244).(output).toStdStringcxx . . $ QString#toStdString(219584694fe2b248).()); |
| 185 | } |
| 186 | } |
| 187 | void UtilityRunnercxx . . $ UtilityRunner#::readStandardErrorcxx . . $ UtilityRunner#readStandardError(49f6e7a06ebc5aa8).() |
| 188 | { |
| 189 | if (mProcesscxx . . $ UtilityRunner#mProcess. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) return; |
| 190 | mProcesscxx . . $ UtilityRunner#mProcess.->setReadChannelcxx . . $ QProcess#setReadChannel(bf19820e89ffcdec).(QProcesscxx . . $ QProcess#::StandardErrorcxx . . $ QProcess#StandardError.); |
| 191 | while (true) |
| 192 | { |
| 193 | QByteArraycxx . . $ QByteArray# output = mProcesscxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).->readLinecxx . . $ QIODevice#readLine(1117a85f2fd4e5c8).(); |
| 194 | if (output.lengthcxx . . $ QByteArray#length(455f465bc33b4cdf).() == 0) break; |
| 195 | output.replacecxx . . $ QByteArray#replace(cd67646238f92a01).('\n','\0'); |
| 196 | output.replacecxx . . $ QByteArray#replace(cd67646238f92a01).('\r','\0'); |
| 197 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(2,"util runner err:" << output.data()); |
| 198 | updateStatuscxx . . $ UtilityRunner#updateStatus(9c546c94e5fcce4e).(QStringcxx . . $ QString#QString(45672f3c6961a244).(output).toStdStringcxx . . $ QString#toStdString(219584694fe2b248).()); |
| 199 | } |
| 200 | } |