Giter VIP home page Giter VIP logo

fncs's Introduction

Framework for Network Co-Simulation

FNCS 2.0 is simplifying and extending the original FNCS, focusing on the needs to support the development of control algorithms across diverse simulator software packages and hardware.

Table of Contents

How to Install FNCS (Linux)

The FNCS code is available at https://github.com/FNCS/fncs. FNCS depends on two other software libraries,

  1. ZeroMQ, and
  2. its higher-level C binding CZMQ.

In order, the dependencies are linear; build ZeroMQ, then CZMQ, then FNCS.

These steps assume your OS is Linux and you are using a Bash shell. We will be installing all software into a subdirectory of your home directory, i.e., $HOME/FNCS_install.

ZeroMQ

# we are doing everything from your $HOME directory
cd $HOME

# download zeromq
wget http://download.zeromq.org/zeromq-3.2.4.tar.gz
# if you do not have wget, use
# curl -O http://download.zeromq.org/zeromq-3.2.4.tar.gz

# unpack zeromq, change to its directory
tar -xzf zeromq-3.2.4.tar.gz
cd zeromq-3.2.4

# configure, make, and make install 
./configure --prefix=$HOME/FNCS_install
make
make install

CZMQ

Installing CZMQ is like any other software using configure and make. The main challenge is specifying the installation location (--prefix) for CZMQ as well as the location where ZeroMQ was installed. If you installed ZeroMQ as written above, the following will work for you.

# we are doing everything from your $HOME directory
cd $HOME

# download czmq
wget http://download.zeromq.org/czmq-3.0.0-rc1.tar.gz
# if you do not have wget, use
# curl -O http://download.zeromq.org/czmq-3.0.0-rc1.tar.gz

# unpack czmq, change to its directory
tar -xzf czmq-3.0.0-rc1.tar.gz
cd czmq-3.0.0

# configure, make, and make install 
./configure --prefix=$HOME/FNCS_install --with-libzmq=$HOME/FNCS_install
make
make install

FNCS

Installing FNCS is like any other software using configure and make. The main challenge is specifying the installation location (--prefix) for FNCS2 as well as the location where ZeroMQ and CZMQ were installed. If you installed ZeroMQ and CZMQ as written above, the following will work for you.

Please note that you must use your own username to clone the git repository as indicated by below. If while attempting to clone FNCS from the git repository, you get an error "server certificate verification failed," check here for what to do: http://stackoverflow.com/questions/21181231/server-certificate-verification-failed-cafile-etc-ssl-certs-ca-certificates-c.

# we are doing everything from your $HOME directory
cd $HOME

# download FNCS
git clone https://github.com/GridOPTICS/FNCS2.git

# change to FNCS directory
cd FNCS2

# configure, make, and make install 
./configure --prefix=$HOME/FNCS_install --with-zmq=$HOME/FNCS_install
make
make install

How to Run a FNCS Co-Simulation

FNCS co-simulations depend on a server process called the fncs_broker. The simulatiors connect to the broker. Run the installed FNCS broker application and indicate the number of simulators that will connect. This number can be 1 as is sometimes useful for testing.

./fncs_broker 2

Then run a FNCS-capable simulator.

./fncs_player 10m trace.txt

How to Use FNCS Tracer/Player Simulators

When wanting to debug a FNCS-ready simulator in isolation, i.e., without other complex FNCS-ready simulators, it is useful to deploy a tracer and player simulator. The tracer simulator by default will subscribe to all message types and write a trace file. The trace file can then be given to a player simulator to play back the events that occurred. The tracer is a good tool to make sure your simulator is actually publishing values. The player is a good tool to make sure your simulator is receiving published values.

Tracer/Player File Format

# nanoseconds   topic                   value
1               sim1/key                value
1               sim1/objA:objB/key      value
1               sim2/yet                again
10000000001     sim3/key                value2
15000000001     sim1/key2               value

Comments

The file format begins with zero or more optional comments. Comments must begin with the hash (#) and the hash must be placed as the first character of the line.

Events

Each line in the file represents an event. The line is split into three columns based on any arbitrary whitespace except newline.

  1. Time at which the event occurred.
  2. Topic name for the event.
  3. Value of the event.

Events MUST be in increasing sorted order according to the time field. Events are allowed to occur simultaneously, as indicated by the events occurring at 1 nanosecond in the above example.

How Time is Handled

The "time" column is intentionally without units. The comment line used in the example above is not mandatory, rather it is useful to indicate the intended unit for time. A time unit may be enforced later by a command-line parameter given to the FNCS player.

./fncs_player 10m trace.txt
# 10m is 10 minutes
# FNCS recognizes many different time unit strings

FNCS ZPL Config File

The ZeroMQ Property Language (ZPL) defines a minimalistic framing language for specifying property sets, expressed as a hierarchy of name-value property pairs. Details about the ZPL format can be found at the ZeroMQ website.

http://rfc.zeromq.org/spec:4

How to Use the FNCS ZPL Config File

Each simulator should have a corresponding "fncs.zpl" file. By default, the fncs.zpl is assumed to be in the current working directory where the simulator is launched. Otherwise, you can specify the name and/or location of the file using the environment variable FNCS_CONFIG_FILE.

Example fncs.zpl

The following code block is an example of the fncs.zpl file. The inline comments in the code block indicate which fields are required. In short, the only required fields are the name, time_delta, and broker address. The subscriptions are actually optional (think of a weather simulator that only reports the temperature and ignores all others). However, if you specify a subscription, each subscription has some required values and some optional values.

name = sim1                 # required; across the co-simulation, all names must be unique
time_delta = 1s             # required; format is <number><unit>; smallest time step supported by the simulator
broker = tcp://localhost:5570   # required; broker location
values                      # optional; list of exact-string-matching topic subscriptions
    foo                     # required; lookup key
        topic = some_topic  # required; format is any reasonable string (not a regex)
        default = 10        # optional; default value
        type = int          # optional; currently unused; data type
        list = false        # optional; defaults to "false"; whether incoming values queue up (true) or overwrite the last value (false)
    bar                     # see "foo" above
        topic = some_topic  # see "foo" above
        default = 0.1       # see "foo" above; here we used a floating point default
        type = double       # see "foo" above
        list = true         # see "foo" above; this is the only difference between "foo" and "bar" here
Values

The list of exact-string-matching topic subscriptions is intended to model a list of simple key-value pairs. Think of your simulator code and its variables - each variable has a name and its associated value. That is how you would write the list of "values" in the FNCS ZPL file as well as how you would retrieve values at runtime using the string fncs::get_value(string key) or the vector<string> fncs::get_values(string key) functions. In most cases each subscription is for a single value (or array of values perhaps). In some cases, a reduction operation is useful such as when computing a sum of values from individual publishers – we need the values to queue up rather than have the last value overwrite all the others.

Environment Variables

Variable Default Value Description
FNCS_LOG_FILE fncs.log File where log messages go. Currently echoed to stdout as well as this file.
FNCS_CONFIG_FILE fncs.zpl File where configuration stuff goes.
FNCS_NAME N/A Same meaning as what is in the ZPL file. Name of the simulator. Must be globally unique.
FNCS_BROKER* tcp://localhost:5570 Same meaning as what is in the ZPL file. Location of broker endpoint.
FNCS_TIME_DELTA N/A Same meaning as what is in the ZPL file.

* If this environment variable is used with the fncs_broker application, it is best to specify tcp://*:PPPP where PPPP is the port number. If this environment variable is used with a FNCS-ready application, it is best to specify tcp://hostname:PPPP where hostname is the name of the host, e.g., localhost, and PPPP is the port number.

fncs's People

Contributors

afisher1 avatar craig8 avatar jacobhansens avatar jeffdaily avatar palsmt avatar temcdrm avatar trevorhardy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fncs's Issues

Conflicting definition for the type "byte" in "src/fncs.cpp"

I have successfully installed zmq and was trying to install fncs.

I used the following command to compile fncs.

./configure --prefix=$FNCS_INSTALL --with-zmq=$FNCS_INSTALL

It compiled successfully. Then I tried to build the program using make as follows.

make

But it gave me the following error.

make  all-am
make[1]: Entering directory '/home/chandrakishor/fncs'
  CXX      src/fncs.lo
In file included from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/parser.h:46:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   46 |                 std::auto_ptr<Scanner> m_pScanner;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/parser.h:47:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   47 |                 std::auto_ptr<Directives> m_pDirectives;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:9,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/emitter.h:105:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
  105 |                 std::auto_ptr <EmitterState> m_pState;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/node.h:14,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:13,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/iterator.h:20:31: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   20 |                 Iterator(std::auto_ptr<IterPriv> pData);
      |                               ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/node.h:14,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:13,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/iterator.h:36:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   36 |                 std::auto_ptr<IterPriv> m_pData;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:13,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/node.h:43:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   43 |                 std::auto_ptr<Node> Clone() const;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
In file included from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:13,
                 from src/fncs.cpp:36:
./contrib/yaml-cpp/include/yaml-cpp/node.h:117:22: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
  117 |                 std::auto_ptr<NodeOwnership> m_pOwnership;
      |                      ^~~~~~~~
In file included from /usr/include/c++/11/memory:76,
                 from ./contrib/yaml-cpp/include/yaml-cpp/parser.h:12,
                 from ./contrib/yaml-cpp/include/yaml-cpp/yaml.h:8,
                 from src/fncs.cpp:36:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
src/fncs.cpp: In function ‘std::ostream& operator<<(std::ostream&, zframe_t*)’:
src/fncs.cpp:970:5: error: reference to ‘byte’ is ambiguous
  970 |     byte *data = zframe_data (self);
      |     ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:61,
                 from /usr/include/c++/11/algorithm:61,
                 from src/fncs.cpp:5:
/usr/include/c++/11/bits/cpp_type_traits.h:404:30: note: candidates are: ‘enum class std::byte’
  404 |   enum class byte : unsigned char;
      |                              ^~~~
In file included from /home/chandrakishor/FNCS-install/include/czmq.h:19,
                 from src/fncs.cpp:33:
/home/chandrakishor/FNCS-install/include/czmq_prelude.h:381:25: note:                 ‘typedef unsigned char byte’
  381 | typedef unsigned char   byte;           //  Single unsigned byte = 8 bits
      |                         ^~~~
src/fncs.cpp:977:18: error: invalid types ‘<unresolved overloaded function type>[uint {aka unsigned int}]’ for array subscript
  977 |         if (data [char_nbr] < 9 || data [char_nbr] > 127)
      |                  ^
src/fncs.cpp:977:41: error: invalid types ‘<unresolved overloaded function type>[uint {aka unsigned int}]’ for array subscript
  977 |         if (data [char_nbr] < 9 || data [char_nbr] > 127)
      |                                         ^
src/fncs.cpp:986:77: error: invalid types ‘<unresolved overloaded function type>[uint {aka unsigned int}]’ for array subscript
  986 |             sprintf (buffer + strlen (buffer), "%02X", (unsigned char) data [char_nbr]);
      |                                                                             ^
src/fncs.cpp:988:59: error: invalid types ‘<unresolved overloaded function type>[uint {aka unsigned int}]’ for array subscript
  988 |             sprintf (buffer + strlen (buffer), "%c", data [char_nbr]);
      |                                                           ^
make[1]: *** [Makefile:990: src/fncs.lo] Error 1
make[1]: Leaving directory '/home/chandrakishor/fncs'
make: *** [Makefile:576: all] Error 2

It seems there are 2 definitions of the type "byte". One is present in /usr/include/c++/11/bits/cpp_type_traits.h which I'm assuming is a file from the g++ compiler. And the other is present in /home/chandrakishor/FNCS-install/include/czmq_prelude.h.

DLL load error with ctypes if files are not in the same folder

I was getting this error message when I tried to run 'import fncs' even with the location of the libfncs and other DLLs added to the PYTHONPATH env variable.

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import fncs
File "c:\users\battelle (pnnl)\desktop\aditya\fncs\fncs\python\fncs.py", line 11, in
_lib = ctypes.CDLL(libname)
File "C:\Python27\lib\ctypes_init
.py", line 362, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

@jeffdaily mentioned that this was due to the assumption that the ctypes call made in fncs.py assumed files to be in the same folder. The libname passed does not involve the full path.

report effectiveness of real-time mode

When using the real-time mode of the broker, it's not sufficient to report the total wall clock time versus the total simulated time as an average. There could be "bursty" behavior that is lost; certain intervals could take significantly longer to process and therefore real-time mode was not actually achieved. Report the real-time efficiency as an optional CSV output of the broker.

"fmcs.hpp not found" when python setup.py install

xxxxx$ python setup.py install
running install
running build
running build_ext
building 'fncs' extension
creating build
creating build/temp.macosx-10.5-x86_64-2.7
gcc -fno-strict-aliasing -I/xxxx/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/xxxx/anaconda/include/python2.7 -c fncs.cpp -o build/temp.macosx-10.5-x86_64-2.7/fncs.o
fncs.cpp:271:10: fatal error: 'fncs.hpp' file not found

include "fncs.hpp"

     ^

1 error generated.
error: command 'gcc' failed with exit status 1

error on FNCS-Tutorial: "unable to locate tape_file.so"

All the instructions were followed when trying to run the FNCS-Tutorial example.
I have FNCS (zeromq-4.1.4), GridLAB-D and ns-3.26 installed and working, all paths and environment variables set, however it yielded:

galahad@galahad-VirtualBox:~/myFNCS/FNCS-Tutorial/demo-gld-ns3$ 
WARNING  [INIT] : last warning message was repeated 1619 times
WARNING  [INIT] : substation:17 is using the default base power of 100 VA. This could cause instability on your system.
WARNING  [INIT] : power_convergence_value not set - defaulting to 0.01 base_power
WARNING  [INIT] : C250_3: controller has no price ramp
ERROR    [2009-07-21 00:00:00 EDT] : unable to locate tape_file.so
ERROR    [2009-07-21 00:00:00 EDT] : sync_player: Unable to open player file 'phase_C.player' for object 'phase_C_load'
ERROR    [2009-07-21 00:00:00 EDT] : unable to locate tape_file.so
ERROR    [2009-07-21 00:00:00 EDT] : sync_player: Unable to open player file 'AEP_RT_LMP.player' for object '(anon)'
ERROR    [2009-07-21 00:00:00 EDT] : unable to locate tape_file.so
ERROR    [2009-07-21 00:00:00 EDT] : sync_player: Unable to open player file 'phase_A.player' for object 'phase_A_load'
ERROR    [2009-07-21 00:00:00 EDT] : unable to locate tape_file.so
ERROR    [2009-07-21 00:00:00 EDT] : sync_player: Unable to open player file 'phase_B.player' for object 'phase_B_load'
ERROR    [2009-07-21 00:00:00 EDT] : sync_house(obj=1838;H_168): glsolver(char *name='etp'): solver library 'glsolvers.so' not found (No such file or directory)
ERROR    [2009-07-21 00:00:00 EDT] : 2009-07-21 00:00:00 EDT: object H_168 stopped its clock (exec)!
ERROR    [2009-07-21 00:00:00 EDT] : exec halted: synchronization failed
FATAL    [2009-07-21 00:00:00 EDT] : shutdown after simulation stopped prematurely
FncsApplication is missing an output file in CSV format.
**   this message 'FncsApplication is missing...' is repeated another 279 times   **

FATAL    [2009-07-21 00:00:00 EDT] : environment startup failed: No such file or directory
Model profiler results
======================

Class            Time (s) Time (%) msec/obj
---------------- -------- -------- --------
climate            0.398     53.7%    398.0
fncs_msg           0.226     30.5%    226.0
house              0.076     10.3%      0.3
controller         0.013      1.8%      0.1
player             0.011      1.5%      2.8
ZIPload            0.009      1.2%      0.0
triplex_meter      0.004      0.5%      0.0
triplex_line       0.003      0.4%      0.0
auction            0.001      0.1%      1.0
================ ======== ======== ========
Total              0.741    100.0%      0.3

WARNING  [2009-07-21 00:00:00 EDT] : last warning message was repeated 41 times

I searched here and on the Internet, but found nothing.

I have downloaded everything from the GitHub (today) - I set FNCS and GridLAB-D to retrieve develop repositories.

I managed to run this six months ago.

performance improvement via communication domains

Sometimes a simulator only subscribes and/or publishes to one other simulator. For example, GridLAB-D might only exchange data with an associated ns-3 instance running the corresponding network communication model. Since the ns-3 logical clock has nanosecond resolution, and the GridLAB-D logical clock has second resolution, the ns-3 simulator can operate at second resolution with respect to the FNCS logical clock in the broker. This information - which simulators communicate with which others and at what frequency - can be gleaned during initialization. Then in specific cases, the fncs::time_request() can return immediately if it is guaranteed that no other simulator can change its state via an event.

Unable to `import fncs` in python

I get the following error when I try to import fncs. I was able to install the cextension with only warning.

$ python test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    import fncs
ImportError: dlopen(/Users/$USERNAME/Documents/GitRepos/fncs/python/fncs.so, 2): Symbol not found: __ZN4fncs10get_valuesERKSs
  Referenced from: /Users/$USERNAME/Documents/GitRepos/fncs/python/fncs.so
  Expected in: dynamic lookup

Do you know what the problem might be?

initial blank line in config file assumes YAML

If the configuration string is used instead of a config file, and the first line is blank, it assumes a YAML string even if it is a ZPL string.

Here's some python code to reproduce:

import fncs

# embed the ZPL file into the initialize call, 
fncs.initialize("""
name = pydemo
time_delta = 1s
values
    key
        topic = sim1/someval
        default = 10
""")

# run for 100 simulated seconds
for time in range(100):
    granted = fncs.time_request(time)
    assert granted == time
    # do some useful work
    someval = fncs.get_value("key")
    fncs.publish(time) # just to publish something

fncs.finalize()

Problems passing values in GridLAB-D/Fortran co-sim using FAPI

Hi,

I've been working with the new Fortran API and I have successfully performed two co-simulations. One simulation involves passing values between two simple Fortran models. The second simulation consists of the same two Fortran models plus the C++ simB model from one of the tutorials. In this simulation all three simulators successfully passed and received values between each other.

I am currently woking on a third co-simulation composed of a simple GridLAB-D model and one of the simple Fortran models used in the previous simulations. However, I am having trouble passing values between them. I have been able to pass the value of the inverter variable "VA_Out" to Fortran but only in the first time step. Below is the output from the Fortran model named "fapi_A":

My name is 'fapi_A'
I am federate 0 out of 2 other federates
current time is 1, received 1 events
event value
fncs_inverter/inverter_1@fapi_A/VA_Out +57713.6+0j VA
current time is 2, received 0 events
event value
current time is 3, received 0 events
event value

What you see for times 2 and 3 is repeated for the rest of the simulation.
This is the GLD output:

name = fncs_inverter
time_delta = 1000000000ns
broker = tcp://localhost:5570
values
fapi_A/fncs_inverter/inverter_1@fapi_A/VA_Out
topic = fapi_A/fncs_inverter/inverter_1@fapi_A/VA_Out
default = +0+0j VA
list = false

This is are the lines in my GLD configure file:

route "commit:inverter_1.VA_Out -> fapi_A/VA_Out; 0";
subscribe "precommit:inverter_1.VA_Out <- fapi_A/fncs_inverter/inverter_1@fapi_A/VA_Out";

And the Config portion in the Fortran model:

config = "name = fapi_A"//NEW_LINE('A')//&
"time_delta = 1s"//NEW_LINE('A')//&
"broker = tcp://localhost:5570"//NEW_LINE('A')//&
"values"//NEW_LINE('A')//&
" fncs_inverter/inverter_1@fapi_A/VA_Out"//NEW_LINE('A')//&
" topic = fncs_inverter/inverter_1@fapi_A/VA_Out"//NEW_LINE('A')//&
" list = false"//NEW_LINE('A')

The fncs_msg object in the GLD model reads as follows:

object fncs_msg {
name fncs_inverter;
parent inverter_1;
option "transport:hostname localhost, port 5570";
configure solar1.txt;

The full files are attached. I created the GLD configure file and fncs_msg object using the gld-ns3 tutorial as reference but I still don't understand the format of the "route", "subscribe", and "function" parts.

Could you please point out what I am doing wrong? Also if possible, could you please explain the format of "route", "subscribe", etc.?

Best regards,

Victor Ayon

GLD-Fortran.zip

MATLAB and fncs error on initialize

I've gotten this error twice in when trying to run fncs_initialize in MATLAB. I'm unfortunately not able to replicate it.

The first line of the error seems to suggest it is a ZMQ issue (?). Is it possible to add a check in fncs to raise a MATLAB error instead of exiting MATLAB altogether?

>> fncs_initialize()
MATLAB: src/zsys.c:179: zsys_init: Assertion `!s_process_ctx' failed.

------------------------------------------------------------------------
              abort() detected at Fri Nov 18 12:47:58 2016
------------------------------------------------------------------------

Configuration:
  Crash Decoding      : Disabled
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown software
  Current Visual      : None
  Default Encoding    : UTF-8
  GNU C Library       : 2.12 stable
  Host Name           : login3
  MATLAB Architecture : glnxa64
  MATLAB Root         : /apps/matlab/R2016a
  MATLAB Version      : 9.0.0.341360 (R2016a)
  OpenGL              : software
  Operating System    : Linux 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Feb 20 12:17:37 EST 2013 x86_64
  Processor ID        : x86 Family 6 Model 45 Stepping 7, GenuineIntel
  Window System       : No active display

Fault Count: 1


Abnormal termination:
abort()

Register State (from fault):
  RAX = 0000000000000000  RBX = 00007fc33eef2000
  RCX = ffffffffffffffff  RDX = 0000000000000006
  RSP = 00007fc31f2963b8  RBP = 00007fc3082be705
  RSI = 000000000000cf52  RDI = 000000000000cf1a

   R8 = fefefefefefefeff   R9 = ff00000000000000
  R10 = 0000000000000008  R11 = 0000000000000202
  R12 = 00007fc3082be7cd  R13 = 00007fc3082c00cd
  R14 = 0000000000000010  R15 = 00007fc3198ba0f0

  RIP = 0000003545c328a5  EFL = 0000000000000202

   CS = 0033   FS = 0000   GS = 0000

Stack Trace (from fault):
[  0] 0x0000003545c328a5                                   /lib64/libc.so.6+00207013 gsignal+00000053
[  1] 0x0000003545c34085                                   /lib64/libc.so.6+00213125 abort+00000373
[  2] 0x0000003545c2ba1e                                   /lib64/libc.so.6+00178718
[  3] 0x0000003545c2bae0                                   /lib64/libc.so.6+00178912 __assert_perror_fail+00000000
[  4] 0x00007fc308277cb3       /$HOME/FNCS_install/lib/libczmq.so.3+00236723
[  5] 0x00007fc308277cd7       /$HOME/FNCS_install/lib/libczmq.so.3+00236759 zsys_socket+00000023
[  6] 0x00007fc30826fc2d       /$HOME/FNCS_install/lib/libczmq.so.3+00203821 zsock_new_checked+00000077
[  7] 0x00007fc3084ea231       /$HOME/FNCS_install/lib/libfncs.so.1+00066097 _ZN4fncs10initializeENS_6ConfigE+00002721
[  8] 0x00007fc3084ec361       /$HOME/FNCS_install/lib/libfncs.so.1+00074593 _ZN4fncs10initializeEv+00000449
[  9] 0x00007fc30875a7e0 /$HOME/GitRepos/fncs/matlab/fncs_initialize.mexa64+00002016 mexFunction+00000072
[ 10] 0x00007fc32c4168b0 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmex.so+00149680 mexRunMexFile+00000064
[ 11] 0x00007fc32c413214 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmex.so+00135700
[ 12] 0x00007fc32c413db4 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmex.so+00138676
[ 13] 0x00007fc32d1bd505 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_dispatcher.so+00746757 _ZN8Mfh_file16dispatch_fh_implEMS_FviPP11mxArray_tagiS2_EiS2_iS2_+00001509
[ 14] 0x00007fc32d1bd9a0 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_dispatcher.so+00747936 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000032
[ 15] 0x00007fc32a1a91c9 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+09232841
[ 16] 0x00007fc32a2d5dbf /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+10464703
[ 17] 0x00007fc32a2cba5a /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+10422874
[ 18] 0x00007fc32a294911 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+10197265
[ 19] 0x00007fc329d62b2a /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04750122
[ 20] 0x00007fc329d63a4c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04753996
[ 21] 0x00007fc329d61ebc /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04746940
[ 22] 0x00007fc329d5f9ea /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04737514
[ 23] 0x00007fc329d5fdb1 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04738481
[ 24] 0x00007fc329d61a63 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04745827
[ 25] 0x00007fc329d61be9 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+04746217
[ 26] 0x00007fc329e1216f /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+05468527
[ 27] 0x00007fc329e1522a /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+05481002
[ 28] 0x00007fc32a0b7543 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08242499
[ 29] 0x00007fc32a08007e /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08015998
[ 30] 0x00007fc32a084058 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08032344
[ 31] 0x00007fc32a084107 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08032519
[ 32] 0x00007fc32a0fa32c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08516396
[ 33] 0x00007fc32a0fa792 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwm_lxe.so+08517522
[ 34] 0x00007fc32c651d7c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwbridge.so+00200060
[ 35] 0x00007fc32c6529c5 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwbridge.so+00203205 _Z8mnParserv+00000789
[ 36] 0x00007fc32d4a6c13 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00695315
[ 37] 0x00007fc3405b581c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmvm.so+02410524 _ZNK5boost9function0IvEclEv+00000028
[ 38] 0x00007fc32d4a8925 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00702757
[ 39] 0x00007fc32d4a9839 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00706617 _ZN5boost6detail17task_shared_stateINS_3_bi6bind_tIvPFvRKNS_8functionIFvvEEEENS2_5list1INS2_5valueIS6_EEEEEEvE6do_runEv+00000025
[ 40] 0x00007fc33b8898a0 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwms.so+03168416 _ZN5boost6detail22task_base_shared_stateIvE3runEv+00000064
[ 41] 0x00007fc32d4aa717 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00710423
[ 42] 0x00007fc32d4a675a /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00694106
[ 43] 0x00007fc32d819c06 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00969734
[ 44] 0x00007fc32d807b4c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00895820 _ZN5boost6detail8function21function_obj_invoker0ISt8functionIFNS_3anyEvEES4_E6invokeERNS1_15function_bufferE+00000028
[ 45] 0x00007fc32d80821f /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00897567 _ZNK5boost9function0INS_3anyEEclEv+00000031
[ 46] 0x00007fc32d807993 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00895379 _ZN3iqm18PackagedTaskPlugin7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000163
[ 47] 0x00007fc32d4bb71d /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00780061
[ 48] 0x00007fc32d7e9f98 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00774040
[ 49] 0x00007fc32d7d45af /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00685487
[ 50] 0x00007fc32d7d17e3 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwiqm.so+00673763
[ 51] 0x00007fc33ff72a3a /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwservices.so+03443258
[ 52] 0x00007fc33ff718a7 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwservices.so+03438759
[ 53] 0x00007fc33ff7210c /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwservices.so+03440908 _Z25svWS_ProcessPendingEventsiib+00000092
[ 54] 0x00007fc32d4a6ed2 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00696018
[ 55] 0x00007fc32d4a7211 /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00696849
[ 56] 0x00007fc32d493cfd /$ROOT/apps/matlab/R2016a/bin/glnxa64/libmwmcr.so+00617725
[ 57] 0x0000003546807851                             /lib64/libpthread.so.0+00030801
[ 58] 0x0000003545ce890d                                   /lib64/libc.so.6+00952589 clone+00000109
[ 59] 0x0000000000000000                                   <unknown-module>+00000000


This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If this problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/

A technical support engineer might contact you with further information.

Thank you for your help.

MATLAB is exiting because of fatal error
[1]    53018 killed     FNCS_CONFIG_FILE=matlab.zpl matlab -nodesktop -nojvm -nosplash -r

installation of fncs on windows

Hi FNCS team,

I am a PhD student trying to work with fncs for co-simulation with PSSE and gridlabD through FNCS. I am very new to FNCS.

I am unable to verify my installation of fncs on windows. I am using python 2.7 for my work. When I follow the instructions on the building on windows. I can see the .dll files in the C:\Alok\FNCS\fncs\bin\x64\Release\v140\dynamic folder.

I am unable to install the fncs from the setup.py file after this and getting an error of unable to find vcvarsall.bat file. I have Visual Sudio 2015 for building the files in the previous step.

Please let me know what mistake I am doing. If you have any document with a few more detailed steps of using FNCS with windows and python 2.7, it will be very helpful.

Please let me know if you want any further details from my end to understand my situation.

Thanks and regards,
Alok.
[email protected]

Python 3.0 suppport for fncs.py

The following example code is one way of "fixing" it to work with both 2.7 and 3.5 versions of python.

import sys

def initialize(config=None):

    if config:
        if sys.verion_info[0] < 3:
            _initialize_config(config)
        else:
            cbuf = ctypes.create_string_buffer(config.encode())
            _initialize_config(cbuf)
    else:
        _initialize()

fncs.py returns empty list for `get_events`

When communicating with a cpp player using fncs.py, we are unable to use get_events() to return a list of keys - it returns an empty list. The get_value(key) method is also empty. We are trying to communicate with simB.cpp. The simA.cpp <-> simB.cpp works as expected using a broker. simA.py (below) <-> simB.cpp does not work as expected.

import fncs
fncs.initialize("""name = simA
time_delta = 1s
broker = tcp://localhost:5570
values
    key
         topic = simB/object.attribute
     """)

fncs.initialize()

for current_time in range(1,100):

    fncs.publish("object.attribute", "value_from_PythonA")

    print(fncs.get_events()) # empty list

    # value = fncs.get_value(key)

 fncs.finalize()

@jeffdaily is this possibly related to #3 ?

support basic C data types in data streams

Instead of using printf() to convert all published values to a string, allow the publication of all basic C data types. Use automagical data type conversion (where it makes sense).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.