本文整理汇总了C++中Port类的典型用法代码示例。如果您正苦于以下问题:C++ Port类的具体用法?C++ Port怎么用?C++ Port使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Port类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
//open the network
Network yarp;
//open the output port
#ifdef USE_PORTS
Port p; //use port
#else
BufferedPort<Sound> p; // use buffered port
#endif
p.open("/sender");
//get the filename
char filename [255];
if (argc==3)
{
if (strcmp(argv[1],"--file")==0)
strcpy (filename, argv[2]);
else
{
printf ("usage: sound_sender_file --file <filename.wav>\n");
return -1;
}
}
else
{
printf ("usage: sound_sender_file --file <filename.wav>\n");
return -1;
}
//read sound from file and put data in yarp::sig::Sound
Sound s;
yarp::sig::file::soundStreamReader soundReader;
printf("opening file %s\n",filename);
if (soundReader.open(filename)==false)
{
printf("cannot open file\n");
return -1;
}
yarp::os::Network::connect("/sender","/yarphear");
//yarp::os::Time::delay (0.1);
//send data on the network
int CHUNK_SIZE = 4096; //samples
for (int i=0; i<3; i++)
{
printf("sending data...\n",i);
bool complete=false;
soundReader.rewind();
do
{
int current_pos = soundReader.getIndex();
int read_samples = soundReader.readBlock(s,CHUNK_SIZE);
if (read_samples<CHUNK_SIZE) complete=true;
static double old = yarp::os::Time::now();
printf("from sample %d to sample %d, time %.3f\n", current_pos, current_pos+read_samples, yarp::os::Time::now()-old);
old = yarp::os::Time::now();
#ifdef USE_PORTS
p.write(s); //use ports
#else
Sound &r = p.prepare(); //use buffered ports
r=s;
p.write(false);
#endif
}
while (!complete);
printf("loop %d/3 complete, press enter to continue\n", i+1);
while ((getchar()) != '\n');
}
//close file
printf("closing file...\n");
soundReader.close();
printf("finished!\n");
return 0;
}
示例2: configure
bool configure(ResourceFinder &rf) override
{
portName=rf.check("name",Value("/dump")).asString();
if (portName[0]!='/')
portName="/"+portName;
bool saveData=true;
bool videoOn=false;
string videoType=rf.check("videoType",Value("mkv")).asString();
if (rf.check("type"))
{
string optTypeName=rf.find("type").asString();
if (optTypeName=="bottle")
type=bottle;
else if (optTypeName=="image")
{
type=image;
#ifdef ADD_VIDEO
if (rf.check("addVideo"))
videoOn=true;
#endif
}
else if (optTypeName == "image_jpg")
{
type=image;
save_jpeg = true;
}
#ifdef ADD_VIDEO
else if (optTypeName=="video")
{
type=image;
videoOn=true;
saveData=false;
}
#endif
else
{
yError() << "Error: invalid type";
return false;
}
}
else
type=bottle;
dwnsample=rf.check("downsample",Value(1)).asInt32();
rxTime=rf.check("rxTime");
txTime=rf.check("txTime");
string templateDirName=rf.check("dir")?rf.find("dir").asString():portName;
if (templateDirName[0]!='/')
templateDirName="/"+templateDirName;
string dirName;
if (rf.check("overwrite"))
dirName="."+templateDirName;
else
{
// look for a proper directory
int i=0;
do
{
ostringstream checkDirName;
if (i>0)
checkDirName << "." << templateDirName << "_" << setw(5) << setfill('0') << i;
else
checkDirName << "." << templateDirName;
dirName=checkDirName.str();
i++;
}
while (!yarp::os::stat(dirName.c_str()));
}
yarp::os::mkdir_p(dirName.c_str());
q=new DumpQueue();
t=new DumpThread(type,*q,dirName,100,saveData,videoOn,videoType);
if (!t->start())
{
delete t;
delete q;
return false;
}
reporter.setThread(t);
if (type==bottle)
{
p_bottle=new DumpPort<Bottle>(*q,dwnsample,rxTime,txTime);
p_bottle->useCallback();
p_bottle->open(portName);
p_bottle->setStrict();
p_bottle->setReporter(reporter);
}
else
{
p_image=new DumpPort<Image>(*q,dwnsample,rxTime,txTime);
p_image->useCallback();
p_image->open(portName);
//.........这里部分代码省略.........
示例3: close
bool AwareTouch::close()
{
world->close();
eventsPort.close();
return true;
}
示例4: setupDatagramSocket
int setupDatagramSocket(UsageEnvironment& env, Port port) {
if (!initializeWinsockIfNecessary()) {
socketErr(env, "Failed to initialize 'winsock': ");
return -1;
}
int newSocket = createSocket(SOCK_DGRAM);
if (newSocket < 0) {
socketErr(env, "unable to create datagram socket: ");
return newSocket;
}
int reuseFlag = groupsockPriv(env)->reuseFlag;
reclaimGroupsockPriv(env);
if (setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR,
(const char*)&reuseFlag, sizeof reuseFlag) < 0) {
socketErr(env, "setsockopt(SO_REUSEADDR) error: ");
closeSocket(newSocket);
return -1;
}
#if defined(__WIN32__) || defined(_WIN32)
// Windoze doesn't properly handle SO_REUSEPORT or IP_MULTICAST_LOOP
#else
#ifdef SO_REUSEPORT
if (setsockopt(newSocket, SOL_SOCKET, SO_REUSEPORT,
(const char*)&reuseFlag, sizeof reuseFlag) < 0) {
socketErr(env, "setsockopt(SO_REUSEPORT) error: ");
closeSocket(newSocket);
return -1;
}
#endif
#ifdef IP_MULTICAST_LOOP
const u_int8_t loop = 1;
if (setsockopt(newSocket, IPPROTO_IP, IP_MULTICAST_LOOP,
(const char*)&loop, sizeof loop) < 0) {
socketErr(env, "setsockopt(IP_MULTICAST_LOOP) error: ");
closeSocket(newSocket);
return -1;
}
#endif
#endif
// Note: Windoze requires binding, even if the port number is 0
netAddressBits addr = INADDR_ANY;
#if defined(__WIN32__) || defined(_WIN32)
#else
if (port.num() != 0 || ReceivingInterfaceAddr != INADDR_ANY) {
#endif
if (port.num() == 0) addr = ReceivingInterfaceAddr;
MAKE_SOCKADDR_IN(name, addr, port.num());
if (bind(newSocket, (struct sockaddr*)&name, sizeof name) != 0) {
char tmpBuffer[100];
sprintf(tmpBuffer, "bind() error (port number: %d): ",
ntohs(port.num()));
socketErr(env, tmpBuffer);
closeSocket(newSocket);
return -1;
}
#if defined(__WIN32__) || defined(_WIN32)
#else
}
#endif
// Set the sending interface for multicasts, if it's not the default:
if (SendingInterfaceAddr != INADDR_ANY) {
struct in_addr addr;
addr.s_addr = SendingInterfaceAddr;
if (setsockopt(newSocket, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&addr, sizeof addr) < 0) {
socketErr(env, "error setting outgoing multicast interface: ");
closeSocket(newSocket);
return -1;
}
}
return newSocket;
}
示例5: silent
int yarp::serversql::Server::run(int argc, char** argv)
{
Property options;
bool silent(false);
FILE* out;
options.fromCommand(argc, argv, false);
silent = options.check("silent");
out = silent ? tmpfile() : stdout;
fprintf(out, " __ __ ___ ____ ____\n\
\\ \\/ // || _ \\ | _ \\\n\
\\ // /| || |/ / | |/ /\n\
/ // ___ || _ \\ | _/\n\
/_//_/ |_||_| \\_\\|_|\n\
========================\n\n");
if (options.check("help")) {
printf("Welcome to the YARP name server.\n");
printf(" --write Write IP address and socket on the configuration file.\n");
printf(" --config filename.conf Load options from a file.\n");
printf(" --portdb ports.db Store port information in named database.\n");
printf(" Must not be on an NFS file system.\n");
printf(" Set to :memory: to store in memory (faster).\n");
printf(" --subdb subs.db Store subscription information in named database.\n");
printf(" Must not be on an NFS file system.\n");
printf(" Set to :memory: to store in memory (faster).\n");
printf(" --ip IP.AD.DR.ESS Set IP address of server.\n");
printf(" --socket NNNNN Set port number of server.\n");
printf(" --web dir Serve web resources from given directory.\n");
printf(" --no-web-cache Reload pages from file for each request.\n");
printf(" --ros Delegate pub/sub to ROS name server.\n");
printf(" --silent Start in silent mode.\n");
//this->stop();
if (silent) {
fclose(out);
}
return 0;
} else {
fprintf(out, "Call with --help for information on available options\n");
}
NameServerContainer nc;
if (!nc.open(options)) {
return 1;
}
nc.setSilent(silent);
bool ok = false;
NameServerManager name(nc);
BootstrapServer fallback(name);
Port server;
Contact alt;
yarp::os::Bottle cmd;
yarp::os::Bottle reply;
double messageCounter(0);
double pollingRate(.1);
name.setPort(server);
server.setReaderCreator(name);
ok = server.open(nc.where(),false);
if (!ok) {
fprintf(stderr, "Name server failed to open\n");
return 1;
}
printf("\n");
fallback.start();
// Repeat registrations for the server and fallback server -
// these registrations are more complete.
fprintf(out, "Registering name server with itself:\n");
nc.preregister(nc.where());
nc.preregister(fallback.where());
alt = nc.whereDelegate();
if (alt.isValid()) {
nc.preregister(alt);
}
nc.goPublic();
//Setting nameserver property
cmd.addString("set");
cmd.addString(server.getName());
cmd.addString("nameserver");
cmd.addString("true");
yarp::os::impl::NameClient::getNameClient().send(cmd, reply);
fprintf(out, "Name server can be browsed at http://%s:%d/\n",
nc.where().getHost().c_str(), nc.where().getPort());
fprintf(out, "\nOk. Ready!\n");
while(!shouldStop) {
messageCounter += pollingRate;
SystemClock::delaySystem(pollingRate);
//.........这里部分代码省略.........
示例6: SparseCoderPort
SparseCoderPort(ResourceFinder &_rf)
:BufferedPort<Image>(),rf(_rf)
{
ipl=NULL;
help=false;
verbose=rf.check("verbose");
grid_step=rf.check("grid_step",Value(8)).asInt();
grid_scale=rf.check("grid_scale",Value(1)).asInt();
contextPath=rf.getHomeContextPath().c_str();
string dictionary_name=rf.check("dictionary_file",Value("dictionary_bow.ini")).asString().c_str();
string dictionary_path=rf.findFile(dictionary_name);
if(dictionary_path=="")
dictionary_path=contextPath+"/"+dictionary_name;
string dictionary_group=rf.check("dictionary_group",Value("DICTIONARY")).asString().c_str();
no_code=rf.check("no_code");
dump_sift=rf.check("dump_sift");
if(dump_sift)
{
string sift_path=rf.check("dump_sift",Value("sift.txt")).asString().c_str();
sift_path=contextPath+"/"+sift_path;
string sift_write_mode=rf.check("append")?"a":"w";
fout_sift=fopen(sift_path.c_str(),sift_write_mode.c_str());
}
rate=rf.check("rate",Value(0.0)).asDouble();
dense=rf.check("useDense",Value(1)).asInt();
int knn=rf.check("KNN",Value(5)).asInt();
last_read=0.0;
pyramidLevels=rf.check("PyramidLevels",Value(3)).asInt();
if(dense)
fprintf(stdout,"Step: %d Scale: %d Pyramid: %d Using Dense SIFT Grid\n",grid_step, grid_scale, pyramidLevels);
else
fprintf(stdout,"Step: %d Scale: %d Pyramid: %d Using Sparse SIFTs \n",grid_step, grid_scale, pyramidLevels);
string code_mode_string=rf.check("code_mode",Value("SC")).asString().c_str();
sparse_coder=NULL;
sparse_coder=new DictionaryLearning(dictionary_path,dictionary_group,code_mode_string,knn);
//set all chars to lower case
for(int i=0; i<code_mode_string.size(); i++)
code_mode_string[i] = std::toupper((unsigned char)code_mode_string[i]);
fprintf(stdout,"%s\n",code_mode_string.c_str());
if(code_mode_string=="SC")
code_mode=CODE_MODE_SC;
if(code_mode_string=="BCE")
code_mode=CODE_MODE_BCE;
if(code_mode_string=="BOW")
code_mode=CODE_MODE_BOW;
string name=rf.find("name").asString().c_str();
port_out_img.open(("/"+name+"/img:o").c_str());
port_out_code.open(("/"+name+"/code:o").c_str());
BufferedPort<Image>::useCallback();
}
示例7: main
int main(int argc, char * argv[])
{
Network yarp;
Time::turboBoost();
ResourceFinder rf;
rf.setVerbose(true);
rf.setDefaultConfigFile("pythonInterface.ini"); //overridden by --from parameter
rf.setDefaultContext("eMorphApplication/conf"); //overridden by --context parameter
rf.configure("ICUB_ROOT", argc, argv);
printf("HELP \n");
printf("--rpcport /icub/rpc \n");
printf("--request 'command:help;command:quit;command:set,int:10;command:set,double:10.0 string:Hello ' \n");
// extracting running paramenter
/* get the module name which will form the stem of all module port names */
ConstString moduleName = rf.check("name",
Value("/logSort"),
"module name (string)").asString();
/* get the module name which will form the stem of all module port names */
ConstString externPort = rf.check("rpcport",
Value("null"),
"rpc port name (string)").asString();
/* get the module name which will form the stem of all module port names */
string requestList = (string) rf.check("request",
Value("null"),
"requests list (string)").asString();
//initialisation
size_t foundColon, foundSemicolon, foundComma;
string subpart, typeCommand, valueCommand;
Bottle in;
Bottle bot; //= _pOutPort->prepare();
bot.clear();
printf("Performing request on %s \n", externPort.c_str());
Port outPort;
outPort.open("/pythonInterface/request");
printf("Connecting ports... \n");
Network::connect("/pythonInterface/request", externPort.c_str());
printf("Connection ultimated \n");
// extracting commands
printf("Request list: %s \n", requestList.c_str());
foundSemicolon = requestList.find(';');
while(foundSemicolon!=string::npos) {
foundComma = requestList.find(',');
while(foundComma<foundSemicolon) {
subpart = requestList.substr(0,foundComma);
printf("subpart : %s \n", subpart.c_str());
requestList = requestList.substr(foundComma + 1);
printf("requestList: %s \n", requestList.c_str());
//interpreting the type of request
foundColon = subpart.find(':');
typeCommand = subpart.substr(0,foundColon);
printf(" typeCommand : %s \n", typeCommand.c_str());
if(!strcmp(typeCommand.c_str(),"command")) {
printf(" this is a command \n");
valueCommand = subpart.substr(foundColon + 1);
printf(" valueCommand : %s \n", valueCommand.c_str());
bot.addVocab(fetchCommand(valueCommand));
}
else if(!strcmp(typeCommand.c_str(),"int")) {
printf(" this is the intege %s. \n", valueCommand.c_str());
bot.addInt(atoi(valueCommand.c_str()));
}
else if(!strcmp(typeCommand.c_str(),"string")) {
valueCommand = subpart.substr(foundColon + 1);
printf(" this is the string %s \n", valueCommand.c_str());
bot.addString(valueCommand.c_str());
}
foundComma = requestList.find(',');
foundSemicolon = requestList.find(';');
}
subpart = requestList.substr(0,foundSemicolon);
printf("subpart : %s \n", subpart.c_str());
requestList = requestList.substr(foundSemicolon + 1);
printf("requestList: %s \n", requestList.c_str());
//interpreting the type of request
foundColon = subpart.find(':');
typeCommand = subpart.substr(0,foundColon);
printf(" typeCommand : %s \n", typeCommand.c_str());
if(!strcmp(typeCommand.c_str(),"command")) {
printf(" this is a command \n");
valueCommand = subpart.substr(foundColon + 1);
printf(" valueCommand : %s \n", valueCommand.c_str());
bot.addVocab(fetchCommand(valueCommand));
}
else if(!strcmp(typeCommand.c_str(),"int")) {
valueCommand = subpart.substr(foundColon + 1);
printf(" this is the integer %s \n", valueCommand.c_str());
bot.addInt(atoi(valueCommand.c_str()));
}
else if(!strcmp(typeCommand.c_str(),"string")) {
valueCommand = subpart.substr(foundColon + 1);
//.........这里部分代码省略.........
示例8: getPort
/** @cond doxygenLibsbmlInternal */
void CompModelPlugin::resetPorts()
{
for (unsigned int p=0; p<getNumPorts(); p++) {
Port* port = getPort(p);
SBase* referenced = port->getReferencedElement();
if (port->isSetSBaseRef()) {
port->unsetSBaseRef();
port->unsetIdRef();
port->unsetMetaIdRef();
port->unsetUnitRef();
int type = referenced->getTypeCode();
if (referenced->isSetId() &&
type != SBML_INITIAL_ASSIGNMENT &&
type != SBML_ASSIGNMENT_RULE &&
type != SBML_RATE_RULE &&
type != SBML_EVENT_ASSIGNMENT) {
if (type==SBML_UNIT_DEFINITION) {
port->setUnitRef(referenced->getId());
}
else {
port->setIdRef(referenced->getId());
}
}
else if (referenced->isSetMetaId()) {
port->setMetaIdRef(referenced->getMetaId());
}
else {
stringstream newname;
newname << "auto_port_" << p;
referenced->setMetaId(newname.str());
port->setMetaIdRef(newname.str());
}
}
port->clearReferencedElement();
}
}
示例9: configure
virtual bool configure(ResourceFinder &rf)
{
Time::turboBoost();
fprintf(stderr, "Getting projections\n");
Matrix PiRight;
Bottle b;
b = rf.findGroup("CAMERA_CALIBRATION_RIGHT");
//fprintf(stderr, "CAMERA_CALIBRATION_RIGHT contains: %s\n", b.toString().c_str());
if (getProjectionMatrix(b, PiRight) == 0)
{
fprintf(stderr, "CAMERA_CALIBRATION_RIGHT was missing some params\n");
return false;
}
else
{
fprintf(stderr, "Working with RightProjection \n");
for (int i=0; i < PiRight.rows(); i++)
fprintf(stderr, "%s\n", PiRight.getRow(i).toString().c_str());
}
Matrix PiLeft;
b = rf.findGroup("CAMERA_CALIBRATION_LEFT");
//fprintf(stderr, "CAMERA_CALIBRATION_LEFT contains: %s\n", b.toString().c_str());
if (getProjectionMatrix(b, PiLeft) == 0)
{
fprintf(stderr, "CAMERA_CALIBRATION_LEFT was missing some params\n");
return false;
}
else
{
fprintf(stderr, "Working with LeftProjection \n");
for (int i=0; i < PiLeft.rows(); i++)
fprintf(stderr, "%s\n", PiLeft.getRow(i).toString().c_str());
}
int period=50;
if (rf.check("period"))
period=rf.find("period").asInt();
bool enableKalman=false;
if (rf.check("kalman"))
enableKalman=true;
string ctrlName=rf.find("name").asString().c_str();
string robotName=rf.find("robot").asString().c_str();
fprintf(stderr, "Initializing eT\n");
eT=new eyeTriangulation(rf, PiLeft, PiRight, enableKalman, period, ctrlName, robotName);
Vector xr(3); xr(0)=PiRight(0,2); xr(1)=PiRight(1,2); xr(2)=1.0;
Vector xl(3); xl(0)=PiLeft(0,2); xl(1)=PiLeft(1,2); xl(2)=1.0;
eT->xInit(xl, xr);
if (rf.check("const"))
eT->xSetConstant(xl, xr);
eT->start();
string rpcPortName="/"+ctrlName+"/rpc";
rpcPort.open(rpcPortName.c_str());
attach(rpcPort);
return true;
}
示例10: main
int main(int argc, char *argv[]){
Network yarp;
//Port<Bottle> armPlan;
//Port<Bottle> armPred;
Port armPlan;
Port armPred;
armPlan.open("/randArm/plan");
armPred.open("/randArm/pred");
bool fwCvOn = 0;
fwCvOn = Network::connect("/randArm/plan","/fwdConv:i");
fwCvOn *= Network::connect("/fwdConv:o","/randArm/pred");
if (!fwCvOn){
printf("Please run command:\n ./fwdConv --input /fwdConv:i --output /fwdConv:o");
return 1;
}
const gsl_rng_type *T;
gsl_rng *r;
gsl_rng_env_setup();
T = gsl_rng_default;
r = gsl_rng_alloc(T);
Property params;
params.fromCommand(argc,argv);
if (!params.check("robot")){
fprintf(stderr, "Please specify robot name");
fprintf(stderr, "e.g. --robot icub");
return -1;
}
std::string robotName = params.find("robot").asString().c_str();
std::string remotePorts = "/";
remotePorts += robotName;
remotePorts += "/";
if (params.check("side")){
remotePorts += params.find("side").asString().c_str();
}
else{
remotePorts += "left";
}
remotePorts += "_arm";
std::string localPorts = "/randArm/cmd";
Property options;
options.put("device", "remote_controlboard");
options.put("local", localPorts.c_str());
options.put("remote", remotePorts.c_str());
PolyDriver robotDevice(options);
if (!robotDevice.isValid()){
printf("Device not available. Here are known devices: \n");
printf("%s", Drivers::factory().toString().c_str());
Network::fini();
return 1;
}
IPositionControl *pos;
IEncoders *enc;
bool ok;
ok = robotDevice.view(pos);
ok = ok && robotDevice.view(enc);
if (!ok){
printf("Problems acquiring interfaces\n");
return 0;
}
int nj = 0;
pos->getAxes(&nj);
Vector encoders;
Vector command;
Vector commandCart;
Vector tmp;
encoders.resize(nj);
tmp.resize(nj);
command.resize(nj);
commandCart.resize(nj);
for (int i = 0; i < nj; i++) {
tmp[i] = 25.0;
}
pos->setRefAccelerations(tmp.data());
for (int i = 0; i < nj; i++) {
tmp[i] = 5.0;
pos->setRefSpeed(i, tmp[i]);
}
command = 0;
//set the arm joints to "middle" values
command[0] = -45;
command[1] = 45;
command[2] = 0;
command[3] = 45;
pos->positionMove(command.data());
bool done = false;
while (!done){
//.........这里部分代码省略.........
示例11: TEST
// This test ensures we don't break the API when it comes to JSON
// representation of tasks.
TEST(HTTPTest, ModelTask)
{
TaskID taskId;
taskId.set_value("t");
SlaveID slaveId;
slaveId.set_value("s");
ExecutorID executorId;
executorId.set_value("t");
FrameworkID frameworkId;
frameworkId.set_value("f");
TaskState state = TASK_RUNNING;
vector<TaskStatus> statuses;
TaskStatus status;
status.mutable_task_id()->CopyFrom(taskId);
status.set_state(state);
status.mutable_slave_id()->CopyFrom(slaveId);
status.mutable_executor_id()->CopyFrom(executorId);
status.set_timestamp(0.0);
statuses.push_back(status);
Labels labels;
labels.add_labels()->CopyFrom(createLabel("ACTION", "port:7987 DENY"));
Ports ports;
Port* port = ports.add_ports();
port->set_number(80);
port->mutable_labels()->CopyFrom(labels);
DiscoveryInfo discovery;
discovery.set_visibility(DiscoveryInfo::CLUSTER);
discovery.set_name("discover");
discovery.mutable_ports()->CopyFrom(ports);
TaskInfo taskInfo;
taskInfo.set_name("task");
taskInfo.mutable_task_id()->CopyFrom(taskId);
taskInfo.mutable_slave_id()->CopyFrom(slaveId);
taskInfo.mutable_command()->set_value("echo hello");
taskInfo.mutable_discovery()->CopyFrom(discovery);
Task task = createTask(taskInfo, state, frameworkId);
task.add_statuses()->CopyFrom(statuses[0]);
JSON::Value object = model(task);
Try<JSON::Value> expected = JSON::parse(
"{"
" \"executor_id\":\"\","
" \"framework_id\":\"f\","
" \"id\":\"t\","
" \"name\":\"task\","
" \"resources\":"
" {"
" \"cpus\":0,"
" \"disk\":0,"
" \"gpus\":0,"
" \"mem\":0"
" },"
" \"slave_id\":\"s\","
" \"state\":\"TASK_RUNNING\","
" \"statuses\":"
" ["
" {"
" \"state\":\"TASK_RUNNING\","
" \"timestamp\":0"
" }"
" ],"
" \"discovery\":"
" {"
" \"name\":\"discover\","
" \"ports\":"
" {"
" \"ports\":"
" ["
" {"
" \"number\":80,"
" \"labels\":"
" {"
" \"labels\":"
" ["
" {"
" \"key\":\"ACTION\","
" \"value\":\"port:7987 DENY\""
" }"
" ]"
" }"
" }"
" ]"
" },"
" \"visibility\":\"CLUSTER\""
" }"
//.........这里部分代码省略.........
示例12: setC
bool Thread::
setC(ticks_t time, ResourceID resID, uint32_t val)
{
Resource *res = getParent().getResourceByID(resID);
if (!res) {
return false;
}
if (val == SETC_INUSE_OFF || val == SETC_INUSE_ON)
return res->setCInUse(*this, val == SETC_INUSE_ON, time);
if (!res->isInUse())
return false;
if (extractBits(val, SETC_MODE_SHIFT, SETC_MODE_SIZE) == SETC_MODE_LONG) {
uint32_t lmode = extractBits(val, SETC_LMODE_SHIFT, SETC_LMODE_SIZE);
uint32_t valField = extractBits(val, SETC_VALUE_SHIFT, SETC_VALUE_SIZE);
switch (lmode) {
default: break;
case SETC_LMODE_PIN_DELAY:
if (res->getType() == RES_TYPE_PORT) {
Port *port = static_cast<Port*>(res);
return port->setPinDelay(*this, valField, time);
}
return false;
case SETC_LMODE_FALL_DELAY:
case SETC_LMODE_RISE_DELAY:
if (res->getType() == RES_TYPE_CLKBLK) {
ClockBlock *clock = static_cast<ClockBlock*>(res);
return clock->setEdgeDelay(*this, getEdgeTypeFromLMode(lmode), valField,
time);
}
return false;
}
}
switch (val) {
default:
internalError(*this, __FILE__, __LINE__); // TODO
case SETC_IE_MODE_EVENT:
case SETC_IE_MODE_INTERRUPT:
{
if (!res->isEventable())
return false;
EventableResource *ER = static_cast<EventableResource *>(res);
ER->setInterruptMode(*this, val == SETC_IE_MODE_INTERRUPT);
break;
}
case SETC_COND_FULL:
case SETC_COND_AFTER:
case SETC_COND_EQ:
case SETC_COND_NEQ:
{
if (!res->setCondition(*this, setCCondition(val), time))
return false;
break;
}
case SETC_RUN_STARTR:
case SETC_RUN_STOPR:
{
if (res->getType() != RES_TYPE_CLKBLK)
return false;
ClockBlock *clock = static_cast<ClockBlock*>(res);
if (val == SETC_RUN_STARTR)
clock->start(*this, time);
else
clock->stop(*this, time);
break;
}
case SETC_MS_MASTER:
case SETC_MS_SLAVE:
if (res->getType() != RES_TYPE_PORT)
return false;
return static_cast<Port*>(res)->setMasterSlave(*this, getMasterSlave(val),
time);
case SETC_BUF_BUFFERS:
case SETC_BUF_NOBUFFERS:
if (res->getType() != RES_TYPE_PORT)
return false;
return static_cast<Port*>(res)->setBuffered(*this, val == SETC_BUF_BUFFERS,
time);
case SETC_RDY_NOREADY:
case SETC_RDY_STROBED:
case SETC_RDY_HANDSHAKE:
if (res->getType() != RES_TYPE_PORT)
return false;
return static_cast<Port*>(res)->setReadyMode(*this, getPortReadyMode(val),
time);
case SETC_PORT_DATAPORT:
case SETC_PORT_CLOCKPORT:
case SETC_PORT_READYPORT:
if (res->getType() != RES_TYPE_PORT)
return false;
return static_cast<Port*>(res)->setPortType(*this, getPortType(val), time);
case SETC_RUN_CLRBUF:
{
if (res->getType() != RES_TYPE_PORT)
return false;
static_cast<Port*>(res)->clearBuf(*this, time);
break;
}
case SETC_INV_INVERT:
case SETC_INV_NOINVERT:
if (res->getType() != RES_TYPE_PORT)
//.........这里部分代码省略.........
示例13: probe_ports
static status_t
probe_ports()
{
// Try to determine what ports to use. We use the following heuristic:
// * Check for DisplayPort, these can be more or less detected reliably.
// * Check for HDMI, it'll fail on devices not having HDMI for us to fall
// back to DVI.
// * Assume DVI B if no HDMI and no DisplayPort is present, confirmed by
// reading EDID in the IsConnected() call.
// * Check for analog if possible (there's a detection bit on PCH),
// otherwise the assumed presence is confirmed by reading EDID in
// IsConnected().
TRACE("adpa: %08" B_PRIx32 "\n", read32(INTEL_ANALOG_PORT));
TRACE("dova: %08" B_PRIx32 ", dovb: %08" B_PRIx32
", dovc: %08" B_PRIx32 "\n", read32(INTEL_DIGITAL_PORT_A),
read32(INTEL_DIGITAL_PORT_B), read32(INTEL_DIGITAL_PORT_C));
TRACE("lvds: %08" B_PRIx32 "\n", read32(INTEL_DIGITAL_LVDS_PORT));
gInfo->port_count = 0;
for (int i = INTEL_PORT_A; i <= INTEL_PORT_D; i++) {
Port* displayPort = new(std::nothrow) DisplayPort((port_index)i);
if (displayPort == NULL)
return B_NO_MEMORY;
if (displayPort->IsConnected())
gInfo->ports[gInfo->port_count++] = displayPort;
else
delete displayPort;
}
// Digital Display Interface
if (gInfo->shared_info->device_type.HasDDI()) {
for (int i = INTEL_PORT_A; i <= INTEL_PORT_E; i++) {
Port* ddiPort
= new(std::nothrow) DigitalDisplayInterface((port_index)i);
if (ddiPort == NULL)
return B_NO_MEMORY;
if (ddiPort->IsConnected())
gInfo->ports[gInfo->port_count++] = ddiPort;
else
delete ddiPort;
}
}
// Ensure DP_A isn't already taken (or DDI)
if (!has_connected_port((port_index)INTEL_PORT_A, INTEL_PORT_TYPE_ANY)) {
// also always try eDP, it'll also just fail if not applicable
Port* eDPPort = new(std::nothrow) EmbeddedDisplayPort();
if (eDPPort == NULL)
return B_NO_MEMORY;
if (eDPPort->IsConnected())
gInfo->ports[gInfo->port_count++] = eDPPort;
else
delete eDPPort;
}
for (int i = INTEL_PORT_B; i <= INTEL_PORT_D; i++) {
if (has_connected_port((port_index)i, INTEL_PORT_TYPE_ANY)) {
// Ensure port not already claimed by something like DDI
continue;
}
Port* hdmiPort = new(std::nothrow) HDMIPort((port_index)i);
if (hdmiPort == NULL)
return B_NO_MEMORY;
if (hdmiPort->IsConnected())
gInfo->ports[gInfo->port_count++] = hdmiPort;
else
delete hdmiPort;
}
if (!has_connected_port(INTEL_PORT_ANY, INTEL_PORT_TYPE_ANY)) {
// there's neither DisplayPort nor HDMI so far, assume DVI B
Port* dviPort = new(std::nothrow) DigitalPort(INTEL_PORT_B);
if (dviPort == NULL)
return B_NO_MEMORY;
if (dviPort->IsConnected()) {
gInfo->ports[gInfo->port_count++] = dviPort;
gInfo->head_mode |= HEAD_MODE_B_DIGITAL;
} else
delete dviPort;
}
// always try the LVDS port, it'll simply fail if not applicable
Port* lvdsPort = new(std::nothrow) LVDSPort();
if (lvdsPort == NULL)
return B_NO_MEMORY;
if (lvdsPort->IsConnected()) {
gInfo->ports[gInfo->port_count++] = lvdsPort;
gInfo->head_mode |= HEAD_MODE_LVDS_PANEL;
gInfo->head_mode |= HEAD_MODE_B_DIGITAL;
} else
delete lvdsPort;
// then finally always try the analog port
//.........这里部分代码省略.........
示例14: getNameSpace
bool NetworkBase::write(const Contact& contact,
PortWriter& cmd,
PortReader& reply,
const ContactStyle& style) {
if (!getNameSpace().serverAllocatesPortNumbers()) {
// switch to more up-to-date method
Port port;
port.setAdminMode(style.admin);
port.openFake("network_write");
Contact ec = contact;
if (style.carrier!="") {
ec = ec.addCarrier(style.carrier);
}
if (!port.addOutput(ec)) {
if (!style.quiet) {
ACE_OS::fprintf(stderr, "Cannot make connection to '%s'\n",
ec.toString().c_str());
}
return false;
}
bool ok = port.write(cmd,reply);
return ok;
}
const char *connectionName = "admin";
ConstString name = contact.getName();
const char *targetName = name.c_str(); // use carefully!
Contact address = contact;
if (!address.isValid()) {
address = getNameSpace().queryName(targetName);
}
if (!address.isValid()) {
if (!style.quiet) {
YARP_SPRINTF1(Logger::get(),error,
"cannot find port %s",
targetName);
}
return false;
}
if (style.timeout>0) {
address.setTimeout((float)style.timeout);
}
OutputProtocol *out = Carriers::connect(address);
if (out==NULL) {
if (!style.quiet) {
YARP_SPRINTF1(Logger::get(),error,
"Cannot connect to port %s",
targetName);
}
return false;
}
if (style.timeout>0) {
out->setTimeout(style.timeout);
}
Route r(connectionName,targetName,
(style.carrier!="")?style.carrier.c_str():"text_ack");
out->open(r);
PortCommand pc(0,style.admin?"a":"d");
BufferedConnectionWriter bw(out->getConnection().isTextMode(),
out->getConnection().isBareMode());
bool ok = true;
if (out->getConnection().canEscape()) {
ok = pc.write(bw);
}
if (!ok) {
if (!style.quiet) {
YARP_ERROR(Logger::get(),"could not write to connection");
}
if (out!=NULL) delete out;
return false;
}
ok = cmd.write(bw);
if (!ok) {
if (!style.quiet) {
YARP_ERROR(Logger::get(),"could not write to connection");
}
if (out!=NULL) delete out;
return false;
}
if (style.expectReply) {
bw.setReplyHandler(reply);
}
out->write(bw);
if (out!=NULL) {
delete out;
out = NULL;
}
return true;
}
示例15: fNext
destRecord
::destRecord(struct in_addr const& addr, Port const& port, u_int8_t ttl, unsigned sessionId,
destRecord* next)
: fNext(next), fGroupEId(addr, port.num(), ttl), fSessionId(sessionId) {
}