|
|
| Author |
Message |
|
| hbunjes |
Posted: Mon May 10, 2010 4:07 pm |
|
|
|
Joined: 10 May 2010
Posts: 5
Location: DE / Region Oldenburg, Bremen
|
I want to create a system that computes a network of virtual sensors.
Several primary (virtual) sensors get new values from the outside every now and then.
Every sensor (primary or secondary) computes a new value when triggered by an incoming new value. After doing this, it sends this new value to several secondary sensors.
I will have lets say 100000 sensors and 100 new values per second from the outside.
Thats it.
I would like to code this using an OTP behaviour but gen_server, gen_fsm or gen_event don't seem to fit.
Do you agree?
Do I have to design my own behaviour or is there a fitting behaviour somewhere? |
|
|
| Back to top |
|
| zajda |
Posted: Tue May 11, 2010 6:21 am |
|
|
|
User
Joined: 22 Aug 2009
Posts: 83
|
1. How to define your own behaviour?
You need to define a behaviour-definition module. It exports:
Code: -module( -- here behaviour name -- ).
-export([start_link/1, init/2]).
-export([behaviour_info/1]).
behaviour_info(callbacks) ->
[{ -- some_function_name --, 1},
{ -- some_another_function --, 2}];
Then in your 'implementations' of the behaviour you just have to use
Code:
-module( -- any_name -- ).
-behaviour( -- name of the bahaviour module -- ).
2. What is the best for your case?
I had chance to built similar network and the behaviour was quite simple. You need to have place to perform computations (so lets call it a body of a sensor) and a synchronizing mechanism (something like epochs in genetic algorithm). So it looks like at least 2 callback functions.
Synchronizing is quite tricky. This number of sensors requires taking under consideration delay between layers (primary and secondary). So, I guess you need to maintain also a state inside a sensor, which tells in which epoch/iteration it exists.
Michał Zajda
------------------
Erlang Solutions Ltd |
|
|
| Back to top |
|
| hbunjes |
Posted: Thu May 20, 2010 9:41 am |
|
|
|
Joined: 10 May 2010
Posts: 5
Location: DE / Region Oldenburg, Bremen
|
Thank you zajda!
So you think that it really would be best to implement my own bahaviour, right?
In general I understand how to write my own behaviour, I just hoped that there was a similar behaviour already existing out there which I could use.
But I do not understand what I need synchronization (or something like an epoch) for.
Heiner |
|
|
| Back to top |
|
| zajda |
Posted: Thu May 20, 2010 12:34 pm |
|
|
|
User
Joined: 22 Aug 2009
Posts: 83
|
hmm, implementing your own behaviour is an option.
It may benefit because it will be light-weight (possible to use proc_lib) and implementing new sensors will be more intuitive, however:
- even gen_server would do the job (in handle_info you would capture signals and handle state)
- R14 will bring O(1) mailbox message retrieving, so you won't be jammed even with thousands of signals
- gen_fsm also would be good choice if your sensor works as state machine
The decision is up to you.
The next issue is synchronization. I dont know the whole picture, but what if primary sensors pass values to 2 separate secondary sensors and computations in each of those take different amount of time? After that if we want to summarize some how secondary sensors (lets say do a sum of them) we would like to sum values from the same 'generation' even tough for the second value we have to wait longer time.
There is many more possibilities, including having a sensor which takes input from primary and secondary sensor, and obviously it must take more/less time.
Michał Zajda
------------------
Erlang Solutions Ltd |
|
|
| Back to top |
|
| Audeley |
Posted: Fri Dec 09, 2011 12:42 pm |
|
|
|
Joined: 09 Dec 2011
Posts: 1
Location: USA
|
| basically you want to create a simple networking system therefore you should contact with a software specialist |
_________________ MD health insurance |
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|