Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rieder committed Sep 17, 2024
1 parent 94780d3 commit 4f249a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 42 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ test_results/code.c
test_results/code.cc
test_results/code.f90
gas_interface
interface
test_results/interface-sockets.f90
test_results/interface.cc
test_results/interface.f90
Expand Down
65 changes: 24 additions & 41 deletions src/amuse/community/interface/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from amuse.rfi.core import LegacyFunctionSpecification


class CommonCodeInterface(object):
class CommonCodeInterface:

@legacy_function
def initialize_code():
Expand All @@ -19,13 +19,13 @@ def initialize_code():
"""

function = LegacyFunctionSpecification()
function.result_type = 'int32'
function.result_type = "int32"
function.result_doc = """
0 - OK
Code is initialized
-1 - ERROR
Error happened during initialization, this error needs to be
further specified by every code implemention
further specified by every code implementation
-2 - ERROR
not yet implemented
"""
Expand All @@ -39,13 +39,13 @@ def cleanup_code():
should be called after this code.
"""
function = LegacyFunctionSpecification()
function.result_type = 'int32'
function.result_type = "int32"
function.result_doc = """
0 - OK
Code is initialized
-1 - ERROR
Error happened during cleanup, this error needs to be further
specified by every code implemention -2 - ERROR
specified by every code implementation -2 - ERROR
not yet implemented
"""
return function
Expand All @@ -58,13 +58,13 @@ def commit_parameters():
Called after the parameters have been set or updated.
"""
function = LegacyFunctionSpecification()
function.result_type = 'int32'
function.result_type = "int32"
function.result_doc = """
0 - OK
Code is initialized
-1 - ERROR
Error happened during initialization, this error needs to be
further specified by every code implemention -2 - ERROR
further specified by every code implementation -2 - ERROR
not yet implemented
"""
return function
Expand All @@ -77,13 +77,13 @@ def recommit_parameters():
particles have been loaded).
"""
function = LegacyFunctionSpecification()
function.result_type = 'int32'
function.result_type = "int32"
function.result_doc = """
0 - OK
Model is initialized and evolution can start
-1 - ERROR
Error happened during initialization, this error needs to be
further specified by every code implemention """
further specified by every code implementation """

return function

Expand All @@ -94,37 +94,20 @@ def invoke_state_change(self):
class CommonCode(InCodeComponentImplementation):

def define_state(self, handler):
handler.set_initial_state('UNINITIALIZED')
handler.add_transition(
'UNINITIALIZED', 'INITIALIZED', 'initialize_code')
handler.add_method('INITIALIZED', 'before_get_parameter')
handler.add_method('INITIALIZED', 'before_set_parameter')
handler.add_method('END', 'before_get_parameter')
handler.add_transition('!UNINITIALIZED!STOPPED', 'END', 'cleanup_code')
handler.add_transition('END', 'STOPPED', 'stop', False)
handler.add_method('STOPPED', 'stop')
handler.set_initial_state("UNINITIALIZED")
handler.add_transition("UNINITIALIZED", "INITIALIZED", "initialize_code")
handler.add_method("INITIALIZED", "before_get_parameter")
handler.add_method("INITIALIZED", "before_set_parameter")
handler.add_method("END", "before_get_parameter")
handler.add_transition("!UNINITIALIZED!STOPPED", "END", "cleanup_code")
handler.add_transition("END", "STOPPED", "stop", False)
handler.add_method("STOPPED", "stop")

def define_methods(self, handler):
handler.add_method(
'initialize_code',
(),
(handler.ERROR_CODE)
)

handler.add_method(
'cleanup_code',
(),
(handler.ERROR_CODE)
)

handler.add_method(
'commit_parameters',
(),
(handler.ERROR_CODE)
)

handler.add_method(
'recommit_parameters',
(),
(handler.ERROR_CODE)
)
handler.add_method("initialize_code", (), (handler.ERROR_CODE))

handler.add_method("cleanup_code", (), (handler.ERROR_CODE))

handler.add_method("commit_parameters", (), (handler.ERROR_CODE))

handler.add_method("recommit_parameters", (), (handler.ERROR_CODE))

0 comments on commit 4f249a1

Please sign in to comment.