How can I use the TrafficLight node in Veins 4.7.1 with a custom app?
I tried to add a trafficlight node the same way we add RSU nodes, i.e.:
import org.car2x.veins.nodes.Scenario;
import org.car2x.veins.nodes.TrafficLight;
network EV_Scenario3 extends Scenario
{
#display("bgb=844,629");
submodules:
tl[2]: TrafficLight {
#display("p=150,140;i=veins/node/trafficlight;is=s");
}
}
and define its app in the omnetpp.ini file i.e. *.tl[*].applType = "TrafficLightApp"
This method does not work and I got the following error:
submodule appl: No module type named 'TrafficLightApp' found that
implements module interface
org.car2x.veins.base.modules.ITrafficlightApplLayer (Not in the loaded
NED files?), at
C:\Veins\veins-5.7.1\src\veins\nodes\TrafficLight.ned: 35 -- in module
(omnetpp::cModule) EV_Scenario3.tl[0] (id-7), during network setup
Any Idea how to use this node, and How can I generate it dynamically like the car nodes?
OMNeT++ does not know a module called TrafficLightApp or this module does not implement the ITrafficlightApplLayer interface.
If you have created the module TrafficLightApp already, make sure that it also implements the aforementioned interface.
If you have not created this module already, you need to create (and register) it first.
Please note that Veins 4.7 introduces traffic lights but does not provide an application layer for them. You have to build one yourself, implementing the ITrafficlightApplLayer interface.
Related
I'm trying to run my first Castalia/WSN simulation (testRouting) in Omnet++ including folders with .ned and c++/h files (TestRouting.h , TestRouting.cc and TestRouting.ned) and the .ini file and I have fixed errors that appears at the omnet IDE.
When I start a simulation I receive the error:
Error in module (cModule) SN.node[0].Communication (id=10) during network setup: Submodule Routing: no module type named 'TestRouting' found that implements module interface node.communication.routing.iRouting(not in the loaded NED files ?), at omnetpp-4.6/samples/castalia/src/node/communication/CommunicationModule.ned:32.
I already tried to rebuild OMNeT++ with Castalia as I have read in other proposed solutions, but it didn’t help.
Can you help me?
The error happens because your TestRouting module in TestRouting.ned does not properly implement the node.communication.routing.iRouting module interface.
Your code in the TestRouting.ned file should at least look something like this:
simple TestRouting like node.communication.routing.iRouting
or something similar.
In short: your model code is incorrect...
I want to create a scheduler inheriting cScheduler. Can someone please tell me which are the functions to be written which must override the functions of cscheduler? Currently, I have written the constructor, destructor, startRun, endRun, guessNextEvent, takeNextEvent, putBackEvent. I have also mentioned the class in the initialization file and able to successfully build my project but when I run the simulation I get the error: Class TraCIConnection" not found -- perhaps it's code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels with Define_Module()/Define_Channel().
The mentioned error has absolutely nothing to do with the custom scheduler you are trying to implement. Omnet complains because you are using the TraCIConnection simple module in the simulation while its C++ code is not linked into the simulation. You may need to add the C++ code to the project or link with an external model that provides that.
Class not found perhaps it was not linked in or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel().
As suggested you should use
Define_Module(yourModule)
in your .cc file.
If this gives error, check that all the functions listed in yourModule.h have been also declared in yourModule.cc
I am trying to use a shared controller from a module in my app, but I'm not really sure how to do it. Here's what I want to do:
I have two revel apps, a frontend and backend app. The frontend app is used to show the user-facing site, and the backend app is for admin stuffs.
I created a special controller to connect to database as per the booking sample.
I want both the frontend and backend app to use the same controller, to minimize redundancy.
From the sample, when you want to have one controller database, it roughly translate to this:
type DBController {
*revel.Controller
}
type App {
DBController
}
This works when I want to have only 1 app, but when I want to share the controller to another app, I can't import DBController to the app.
Things I've Tried
I tried moving DBController to its own package, and then importing that and inherit from it directly:
// in db.go
package controllers
// import and stuffs
type DBController {
*revel.Controller
}
// in app.go
package controllers
import (
dbc "site.com/modules/controllers"
)
type App struct {
dbc.DBController
// *dbc.DBController
}
This gives me a panic error stating that the route is not found:
panic: Route validation error (in /app/path/routes:7):
revel/controller: failed to find controller App
in both inheriting with and without pointer.
I've also tried Revel's module, with the same code, but different directory and importing via config:
// app.conf
modules.dbcontroller=site.com/modules/dbcontroller
And then in app.go:
type App struct {
DBController
}
But it still didn't work with the same error as before. I'm pretty convinced that the right route is by using module, since the documentation said (emphasis mine):
Modules are packages that can be plugged into an application. They allow sharing of controllers, views, assets, and other code between multiple Revel applications or from third-party sources.
A module should have the same layout as a Revel application’s layout. The “hosting” application will merge it in as follows:
Any templates in module/app/views will be added to the Template Loader search path
Any controllers in module/app/controllers will be treated as if they were in your application.
etc..
But I'm not sure how I can share and derive my controller from here.
TL; DR
How do I share controller in Revel so that I can inherit a controller from other module, roughly like:
import dbc "site.com/modules/dbcontroller"
type App struct {
dbc.DBController
}
so that DBController can be used with several revel apps? Thank you very much.
I am not an authority, but I will make a few observations that might help even though I do not have a complete answer for you.
The first thing about your question that struck me is the use of the term "inherit" -- Go does not support inheritance. It does support embedding. I might have written the question subject as "Reuse controller from module in Revel framework.
Second, I wonder if you are trying to reuse a Revel module between two separate Revel applications or if you are trying to reuse code from a module in two separate parts of one Revel application that just happens to have a front end and a back end. A quick read of the reveal framework makes me think modules were designed for the former, not the latter.
Third, I wonder if perhaps you are confusing files with packages. It was not obvious to me when learning Go that one package can span multiple files.. if the same declaration of "package controller" exists in two files such as db.go and app.go, they are still in the same package.
I'm currently following the Laravel Package documentation, which uses the workbench tool to create a standard package tree consisting of controller, config, views, etc. folders. Basically, most folders you would get in a standard Laravel app tree.
However, I had a couple of questions:
Why is the models folder absent here? (though the same goes for tests and commands)
Should I just create the folder myself and add it to the composer.json autoload classmap?
What classes should live inside src/<Namespace>/<PackageName>? I have noticed that a ServiceProvider is automatically created here, but I can imagine most other files just existing in the standard package directories.
Wockbench represents just a tool for creating other tools, that is triggered through CLI. Workbench is very abstract concept.
Model folder is absent simply because you don't need model in every new package. For example, if you are creating middleware package or you own filter package.
Every new class can be added to package dependent on its purpose and responsibility. It can be done in more then one way.
Classes that are general enough to go into every package are:
Package Service Provider
Facade
Basic Class
But it is not a black box. Consider for example request class - it is bound very early in the application life cycle, so no provider is needed.