-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration Panel: Add Timeouts for AspenConsumer #1199
Comments
@boverhof basically it would be adding another section under "Settings" called for example "Aspen Configuration Parameters" where the user can specify the path to the XML file and edit the parameters in the UI. I would need the possible paths to this file and a copy of an example file. Thanks! |
@sotorrio1 This is the "template" that gets converted to the XML file: |
@boverhof Thanks! |
There is a complication with the Windows Software, it expects XML namespaces to be declared as the default namespace. I tried using element tree to rewrite the XML Configuration but it declares namespaces with prefixes and the Windows software doesn't understand that.
# -*- coding: utf-8 -*-
"""
"""
import os
from shutil import copyfile
import time
import xml.etree.ElementTree as ET
DIR='\Program Files\Turbine\Lite\Clients'
XML_CONFIG = os.path.join(DIR, 'AspenSinterConsumerConsole.exe.config')
COPY_XML_CONFIG = XML_CONFIG + '-backup-' + str(time.time())
def main():
assert os.path.isdir(DIR)
assert os.path.isfile(XML_CONFIG)
copyfile(XML_CONFIG, COPY_XML_CONFIG)
tree = ET.parse(XML_CONFIG)
root = tree.getroot()
print(root)
node = root.find("./userSettings/Turbine.Console.Properties.Settings/setting[@name='TimeOutIterations']/value")
assert node is not None
print("TEXT: %s" %(node.text))
val = int(node.text)
# Double the Timeout value
val *= 2
print("NEW VALUE: %d" %(val))
node.text = str(val)
tree.write(XML_CONFIG)
if __name__ == '__main__': main() |
@boverhof Can you try if modifying the file like this would work with Aspen? import os
from shutil import copyfile
import time
import re
# Specify the file path
DIR = '\Program Files\Turbine\Lite\Clients'
XML_CONFIG = os.path.join(DIR, 'AspenSinterConsumerConsole.exe.config')
COPY_XML_CONFIG = XML_CONFIG + '-backup-' + str(time.time())
def main():
# Assert directory and file exist
assert os.path.isdir(DIR)
assert os.path.isfile(XML_CONFIG)
# Backup current XML file
copyfile(XML_CONFIG, COPY_XML_CONFIG)
print(f"File '{XML_CONFIG}' successfully backed up in '{COPY_XML_CONFIG}'")
# Define the specific text to find
specific_text = '<setting name="TimeOutIterations" serializeAs="String">'
# Define the regex pattern to find <value>...</value> tags after the specific text
pattern = re.compile(rf"{re.escape(specific_text)}\s*<value>(.*?)</value>")
try:
# Read the entire content of the file
with open(XML_CONFIG, 'r', encoding='utf-8') as file:
content = file.read()
# Find all matches of the pattern in the content
matches = pattern.finditer(content)
# Process each match
for match in matches:
value_text = match.group(1)
start_index = match.start(1)
end_index = match.end(1)
print(f"Found <value>{value_text}</value> after '{specific_text}' at index {start_index} to {end_index}")
current_val = content[start_index:end_index]
print(f"Current Timeout: {current_val}")
# Double timeout value
new_val = int(current_val) * 2
print(f"New Timeout: {new_val}")
# Perform the replacement
if 0 <= start_index < len(content):
# Insert new_text at start_index
content = content[:start_index] + str(new_val) + content[start_index + len(str(new_val)):]
# Write the modified content back to the file
with open(XML_CONFIG, 'w', encoding='utf-8') as file:
file.write(content)
print(f"Successfully replaced text at index {start_index} with '{str(new_val)}'.")
else:
print("Index out of range.")
if not matches:
print(f"No <value>...</value> tags found after '{specific_text}'")
except Exception as e:
print(f"Error: {e}")
if __name__ == '__main__':
main() |
Description
The AspenConsumer executes and manages AspenPlus and ACM flowsheets and is configured to kill the AspenEngine when a time out value is exceeded. This parameter is modifiable in an XML configuration file. The purpose of this issue is to expose these configuration parameters in the FOQUS configuration UI ( screen shot below ). Should read and edit the
AspenSinterConsumerConsole.xml
, display the values in this UI and allow the user to edit it which may require a restart of FOQUS.web API Timeouts
AspenSinterCosumerConsole Timeouts
\Program Files (x86)\Turbine\Lite\Consumers\AspenSinterConsumerConsole.xml
The text was updated successfully, but these errors were encountered: