示例#1
0
 ReturnCode Socket::shutdown()
 {
     MSS_BEGIN(ReturnCode);
     MSS(pimpl_);
     MSS(pimpl_->shutdown());
     MSS_END();
 }
示例#2
0
文件: Read.hpp 项目: RoboBuddie/gubg
 ReturnCode read(char &ch)
 {
     MSS_BEGIN(ReturnCode);
     MSS(it_ != end_, RangeIsEmpty);
     ch = (char)*(it_++);
     MSS_END();
 }
示例#3
0
 ReturnCode Linker::addObject(const gubg::file::File &obj)
 {
     MSS_BEGIN(ReturnCode);
     MSS((bool)itf_);
     itf_->objects.push_back(obj);
     MSS_END();
 }
示例#4
0
 ReturnCode Linker::addOption(const std::string &option)
 {
     MSS_BEGIN(ReturnCode);
     MSS((bool)itf_);
     MSS(itf_->setOption(option), UnknownOption);
     MSS_END();
 }
示例#5
0
 ReturnCode Socket::send(IOBuffer &buffer)
 {
     MSS_BEGIN(ReturnCode);
     MSS(pimpl_);
     MSS(pimpl_->send(buffer));
     MSS_END();
 }
示例#6
0
 ReturnCode Socket::receive(IOBuffer &buffer)
 {
     MSS_BEGIN(ReturnCode);
     MSS(pimpl_);
     MSS(pimpl_->receive(buffer));
     MSS_END();
 }
示例#7
0
 //Public API
 ReturnCode Socket::bind(int port)
 {
     MSS_BEGIN(ReturnCode);
     MSS(createSocket_());
     MSS(pimpl_->bind(port));
     MSS_END();
 }
示例#8
0
 ReturnCode Linker::addLibraryPath(const gubg::file::File &lp)
 {
     MSS_BEGIN(ReturnCode);
     MSS((bool)itf_);
     itf_->libraryPaths.push_back(lp);
     MSS_END();
 }
示例#9
0
 ReturnCode Socket::listen()
 {
     MSS_BEGIN(ReturnCode);
     MSS(pimpl_);
     MSS(pimpl_->listen());
     MSS_END();
 }
示例#10
0
文件: Read.hpp 项目: RoboBuddie/gubg
 ReturnCode read(Type &type)
 {
     MSS_BEGIN(ReturnCode);
     MSS(it_ != end_, RangeIsEmpty);
     MSS(type.read(*(it_++)));
     MSS_END();
 }
/**************************************************************************//**
* 
* task_1
* 
* @brief      task 1 example
*
* @param[in]  param     task parameter input (unused)
* 
* @return     -
* 
******************************************************************************/
void task_1(void *param)
{
  mss_mque_msg_t* msg;

  MSS_BEGIN(task1_ctx);

  while(1)
  {
    // wait for any message in the mque
    MSS_MQUE_WAIT_MSG(mque_hdl, msg, task1_ctx);

    // evaluate message
    if(!memcmp((const char*)msg->data, "LED", 3))
    {
      if(msg->data[3] == '1')
      {
        HAL_LED1_TOGGLE();
      }
      else if(msg->data[3] == '2')
      {
        HAL_LED2_TOGGLE();
      }
    }

    // return memory
    mss_mem_free(mem_hdl, msg);
  }
  
  MSS_FINISH();
}
示例#12
0
                ReturnCode process_()
                {
                    MSS_BEGIN(ReturnCode, logns);

                    Name name;
                    switch (const auto rc = pop_name_(name))
                    {
                        case ReturnCode::OK:
                            break;
                        case ReturnCode::NotFound:
                            MSS_RETURN_OK();
                            break;
                        default: MSS(rc); break;
                    }

                    Attributes attrs;
                    MSS(pop_attrs_(attrs));

                    receiver_().parser_open(name, attrs);

                    pop_whitespace_();
                    if (content_.pop_if('{'))
                    {
                        pop_whitespace_();
                        while (!content_.pop_if('}'))
                        {
                            MSS(process_());
                        }
                    }

                    receiver_().parser_close();

                    MSS_END();
                }
示例#13
0
文件: Read.hpp 项目: RoboBuddie/gubg
 ReturnCode read(unsigned char &b)
 {
     MSS_BEGIN(ReturnCode);
     MSS(it_ != end_, RangeIsEmpty);
     b = (unsigned char)*(it_++);
     MSS_END();
 }
示例#14
0
            ReturnCode computeMeanSigma(Result &mean, Result &sigma, const Values &values, const Weights &weights)
            {
                MSS_BEGIN(ReturnCode);
                MSS(!values.empty());
                MSS(values.size() == weights.size());

                //Compute mean and the sum of the weights
                mean = 0.0;
                Result sumW = 0.0;
                typename Values::const_iterator value = values.begin();
                for (auto weight: weights)
                {
                    mean += *(value++)*weight;
                    sumW += weight;
                }
                mean /= sumW;

                //Compute sigma
                sigma = 0.0;
                typename Weights::const_iterator weight = weights.begin();
                for (auto value: values)
                    sigma += *(weight++)*(value-mean)*(value-mean);
                sigma = ::sqrt(sigma/sumW);

                MSS_END();
            }
示例#15
0
 ReturnCode Linker::addLibrary(const std::string &lib)
 {
     MSS_BEGIN(ReturnCode);
     MSS((bool)itf_);
     itf_->libraries.push_back(lib);
     MSS_END();
 }
示例#16
0
 ReturnCode listen()
 {
     MSS_BEGIN(ReturnCode);
     MSS(state == Bound, InvalidState);
     MSS(::listen(fid, MaxNrWaitingConnections) != -1, CouldNotListen);
     changeState(Listening);
     MSS_END();
 }
示例#17
0
 ReturnCode createConnection(std::shared_ptr<Handler> &handler)
 {
     MSS_BEGIN(ReturnCode);
     Socket socket;
     MSS(socket.connect(ip_, port_));
     handler.reset(new Handler(socket));
     MSS_END();
 }
示例#18
0
文件: State.cpp 项目: lfannes/gubg
	ReturnCode State::execute(const std::string &code)
	{
		MSS_BEGIN(ReturnCode);
		CHECK_AND_LOCK(pimpl_);
		MSS(luaL_loadstring(s, code.c_str()) == 0, CompileError);
		MSS(lua_pcall(s, 0, 0, 0) == 0, RuntimeError);
		MSS_END();
	}
示例#19
0
文件: State.cpp 项目: lfannes/gubg
	ReturnCode State::registerFunction(Function function, const std::string &name)
	{
		MSS_BEGIN(ReturnCode);
		CHECK_AND_LOCK(pimpl_);
		lua_pushcfunction(s, (lua_CFunction)function);
		lua_setglobal(s, name.c_str());
		MSS_END();
	}
示例#20
0
 ReturnCode draw(Domain &value) const
 {
     MSS_BEGIN(ReturnCode);
     size_t ix;
     MSS(weightDistribution_.generate(ix));
     value = drawGaussian(data_[ix], width_);
     MSS_END();
 }
示例#21
0
 ReturnCode setWidth(double width)
 {
     MSS_BEGIN(ReturnCode);
     MSS(width > 0.0, IllegalArgument);
     width_ = width;
     invWidth_ = 1.0/width;
     MSS_END();
 }
示例#22
0
 ReturnCode decodeNumber(Number &number, IInput &input)
 {
     MSS_BEGIN(ReturnCode);
     unsigned long v;
     MSS(decodeNumber(v, input));
     number = v;
     MSS_END();
 }
示例#23
0
 ReturnCode Socket::createSocket_()
 {
     MSS_BEGIN(ReturnCode);
     MSS(!pimpl_, SocketAlreadyPresent);
     int fid = ::socket(PF_INET, SOCK_STREAM, 0);
     MSS(fid != InvalidFID, CouldNotGetSocketDescriptor);
     pimpl_.reset(new Pimpl(fid));
     MSS_END();
 }
示例#24
0
 ReturnCode process(const std::string &content)
 {
     MSS_BEGIN(ReturnCode, logns);
     content_ = gubg::Strange(content);
     const auto rc = process_();
     content_.clear();
     MSS(rc);
     MSS_END();
 }
示例#25
0
 ReturnCode send(IOBuffer &buffer)
 {
     MSS_BEGIN(ReturnCode);
     MSS(state == Connected, InvalidState);
     auto nrSent = ::send(fid, buffer.data(), buffer.size(), 0);
     MSS(nrSent != -1, CouldNotSend);
     buffer.scrollBegin(nrSent);
     MSS_END();
 }
示例#26
0
 ReturnCode Socket::accept(Socket &socket)
 {
     MSS_BEGIN(ReturnCode);
     MSS(pimpl_);
     int fid;
     MSS(pimpl_->accept(fid));
     socket = Socket(fid);
     MSS_END();
 }
示例#27
0
	ReturnCode Library::ctor_(File fn)
	{
		MSS_BEGIN(ReturnCode);
		MSS(resolve(fn));
		MSS(isRegular(fn));
        Handle h;
        MSS(load_(h, fn.name()));
		pimpl_.reset(new Pimpl(h, fn));
		MSS_END();
	}
示例#28
0
 ReturnCode Socket::connect(const string &ip, int port)
 {
     MSS_BEGIN(ReturnCode);
     //TODO::In stead of splitting the socket creation and connect, this should be combined
     //to allow us to use the PF_INET/PF_INET6 settings resolved by getaddrinfo and to be used in
     //the socket creation
     MSS(createSocket_());
     MSS(pimpl_->connect(ip, port));
     MSS_END();
 }
示例#29
0
 ReturnCode learn(const Data &data, double *width = nullptr, const Weights *weights = nullptr)
 {
     MSS_BEGIN(ReturnCode);
     MSS(setData_(data, weights));
     if (width)
         MSS(setWidth(*width));
     else
         MSS(learnWidth());
     MSS_END();
 }
示例#30
0
 ReturnCode computeMean(Mean &mean, const Values &values)
 {
     MSS_BEGIN(ReturnCode);
     MSS(!values.empty());
     mean = 0.0;
     for (auto value: values)
         mean += value;
     mean /= values.size();
     MSS_END();
 }