Ignore:
Timestamp:
07/18/13 23:52:25 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • add auto loading and saving algorithms between

frams files format and Java classes

  • respect ValueChange? events in GUI (do not reload object)
  • support results of procedures in Java server
  • make Experiment automatically convert between frams file and NetFile? object
  • add MessageLogger? (compatible with original frams server messages)
  • WorkPackageLogic? now validates results, is able to discard them, reschedule

whole package, or only uncomputed remainder

CHANGELOG:
Show just a short description in PrimeExperiment?.

Add primes_changed event to the PrimeExperiment?.

Make WorkPackageLogic? robust to frams server returning invalid results.

Add MessageLogger? to logics.

Add NetFile? interface. Support Messages from server.

Minor changes to connections.

Merge results in the PrimeExperiment?.

More netload class->file conversion to Simulator.

Move netsave parsing to Simulator.

Fix bug with inverted ordering of events firing in Experiment.

Minor changes.

Minor logging changes.

Use AccessOperations?.convert in NetLoadSaveLogic?

NetLoadSaveLogic? now encloses the conversion.

Use more generic AccessOperations? saveAll and loadAll in PrimePackage?.

Add Result class for enclosing of call invocations' results.

Improve feature request handling in Connections.

Use AccessOperations?.convert in RemoteTree? events parsing.

Minor change.

Add some information params to Java server root and CLI objects.

A draft implementation of loadAll algorithm.

That algorithm tries to load objects into a tree structure.

Add AccessOperationsTest? test.

Develop WorkPackageLogic?.

  • add state tracking fields
  • add work package generation

Add utility class SimplePrimitive?.

Meant for Java backend classes, enclose a single primitive value
and set of listeners.

Improve primitive value refresh in GUI.

When ValueChange? found in called event, do not reload whole
object, but only update GUI (no communication is performed).

Use ValueChange? in the TestClass? test.

Minor changes.

Sending all packages in PrimeExperiment? to the frams servers.

Develop AccessOperations?.loadComposites().

Remove addAccess from MultiParamLoader? interface.

There is now no default AccessProvider? in MultiParamLoader?.
User must explicitely set AccessStash? or Registry.

Improve saving algorithms in AccessOperations?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/experiment/NetLoadSaveLogic.java

    r102 r103  
    55import org.apache.logging.log4j.LogManager;
    66
    7 import com.framsticks.communication.File;
    87import com.framsticks.core.ListChange;
     8import com.framsticks.core.Message;
    99import com.framsticks.params.EventListener;
     10import com.framsticks.params.MessageLogger;
    1011import com.framsticks.params.annotations.FramsClassAnnotation;
    1112import com.framsticks.params.annotations.ParamAnnotation;
     
    1415
    1516@FramsClassAnnotation
    16 public abstract class NetLoadSaveLogic extends AbstractExperimentLogic {
     17public abstract class NetLoadSaveLogic<NF extends NetFile> extends AbstractExperimentLogic {
    1718        private static final Logger log = LogManager.getLogger(NetLoadSaveLogic.class);
    1819
     20        protected String option = "an option";
    1921
    20         protected String option = "an option";
     22        protected final Class<NF> netJavaClass;
     23
     24        protected final MessageLogger messages = new MessageLogger(NetLoadSaveLogic.class);
    2125
    2226        /**
    2327         * @param experiment
    2428         */
    25         public NetLoadSaveLogic(Experiment parentExperiment) {
     29        public NetLoadSaveLogic(Experiment parentExperiment, Class<NF> netJavaClassArg) {
    2630                super(parentExperiment);
     31                this.netJavaClass = netJavaClassArg;
    2732
    2833                experiment.addSimulatorsListener(new EventListener<ListChange>() {
    2934
    3035                        @Override
    31                         public void action(ListChange argument) {
     36                        public void action(final ListChange change) {
    3237                                assert experiment.isActive();
     38                                final Simulator simulator = experiment.getSimulators().get(change.getIdentifier());
     39                                log.debug("processing list change: {}", change);
    3340
    34                                 if (argument.hasHint("ready")) {
    35                                         final Simulator simulator = experiment.getSimulators().get(argument.getIdentifier());
    36                                         log.debug("simulator is ready: {}", simulator);
     41                                if (change.getAction() == ListChange.Action.Add) {
     42                                        log.debug("registering in {}", simulator);
     43                                        simulator.getRemoteTree().getRegistry().registerAndBuild(netJavaClass);
     44                                }
    3745
    38                                         netload(simulator, new FutureHandler<File>(simulator) {
     46                                if (!change.hasHint("stoped")) {
     47                                        issueNetloadIfReady(change, simulator);
     48                                        return;
     49                                }
    3950
    40                                                 @Override
    41                                                 protected void result(final File file) {
    42                                                         simulator.uploadNet(file, new FutureHandler<Object>(this) {
     51                                log.debug("issuing netsave to: {}", simulator);
     52                                simulator.netsave(netJavaClass, new FutureHandler<NF>(simulator) {
    4353
    44                                                                 @Override
    45                                                                 protected void result(Object result) {
    46                                                                         log.debug("netload of {} done", file);
    47                                                                 }
    48                                                         });
    49                                                 }
    50                                         });
    51                                 }
     54                                        @Override
     55                                        protected void result(NF net) {
     56                                                log.debug("netsave of {} done: {}", simulator, net.getShortDescription());
     57                                                netsave(simulator, net);
     58                                                issueNetloadIfReady(change, simulator);
     59                                        }
     60                                });
    5261                        }
    5362                });
    5463        }
    5564
    56         public abstract void netload(Simulator simulator, Future<File> net);
     65        protected void issueNetloadIfReady(ListChange change, final Simulator simulator) {
     66                if (!change.hasHint("ready")) {
     67                        return;
     68                }
     69                log.debug("issuing netload to: {}", simulator);
     70                netload(simulator, new FutureHandler<NF>(simulator) {
    5771
    58         public abstract void netsave(Simulator simulator, File net);
     72                        @Override
     73                        protected void result(final NF net) {
     74                                if (net == null) {
     75                                        log.debug("no file for upload provided - leaving simulator idle");
     76                                        return;
     77                                }
     78
     79                                simulator.netload(net, new FutureHandler<Object>(this) {
     80
     81                                        @Override
     82                                        protected void result(Object result) {
     83                                                NetLoadSaveLogic.this.messages.info("netload", "done " + net.getShortDescription());
     84                                                log.debug("netload of {} done", net.getShortDescription());
     85                                                simulator.start();
     86                                        }
     87                                });
     88                        }
     89                });
     90        }
     91
     92        public abstract void netload(Simulator simulator, Future<NF> net);
     93
     94        public abstract void netsave(Simulator simulator, NF net);
    5995
    6096        /**
     
    74110        }
    75111
     112        /**
     113         * @return the netJavaClass
     114         */
     115        @ParamAnnotation(name = "Java class representing netfile")
     116        public String getNetJavaClassName() {
     117                return netJavaClass.getCanonicalName();
     118        }
     119
     120        @ParamAnnotation(id = "messages")
     121        public void addMessageListener(EventListener<Message> listener) {
     122                messages.add(listener);
     123        }
     124
     125        @ParamAnnotation(id = "messages")
     126        public void removeMessageListener(EventListener<Message> listener) {
     127                messages.remove(listener);
     128        }
     129
    76130}
Note: See TracChangeset for help on using the changeset viewer.