コード例 #1
0
ファイル: ReadDirectory.cpp プロジェクト: uboot/stromx
 void ReadDirectory::execute(DataProvider& provider)
 {
     if (m_files.size() == 0)
         throw OperatorError(*this, "Directory is empty.");
         
     Data* data = 0;
     std::size_t index = m_currentIndex;
     do
     {
         boost::filesystem::path file(m_files[index]);
         index = (index + 1) % m_files.size();
         std::string ext = file.extension().string();
         std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
         if (ext == ".png" || ext == ".jpg" || ext == ".jpeg")
         {
             data = new cvsupport::Image(file.string());
         }
     }
     while (data == 0 && index != m_currentIndex);
     
     m_currentIndex = index;
     
     if (data == 0)
         throw OperatorError(*this, "Found no usable file in selected directory.");
     
     DataContainer container(data);
     Id2DataPair outputDataMapper(OUTPUT, container);
     provider.sendOutputData(outputDataMapper);
 }
コード例 #2
0
ファイル: ReadGpio.cpp プロジェクト: joccccc/stromx
 void ReadGpio::activate()
 {
     if (impl::GPIOExport(static_cast<int>(m_gpio)))
     {
         throw OperatorError(*this, 
             (boost::format("Failed to export GPIO %1%. Consider running this process as root.") % m_gpio).str());
     }
                             
     if (impl::GPIODirection(static_cast<int>(m_gpio), impl::IN))
     {
         impl::GPIOUnexport(static_cast<int>(m_gpio));
         throw OperatorError(*this, 
             (boost::format("Failed to set direction of GPIO %1%.") % m_gpio).str());
     }
 }
コード例 #3
0
ファイル: ReadDirectory.cpp プロジェクト: uboot/stromx
 void ReadDirectory::activate()
 {
     if (m_directory == NO_DIRECTORY)
         throw OperatorError(*this, "No valid directory selected.");
         
     std::string directory = m_directoryMap[std::size_t(m_directory)];
     
     boost::filesystem::path path(BASE_DIRECTORY);
     path /= boost::filesystem::path(directory);
     
     m_currentIndex = 0;
     m_files.clear();
     if (boost::filesystem::exists(path))
     {
         if (boost::filesystem::is_directory(path))
         {
             for(boost::filesystem::directory_iterator iter(path);
                 iter != boost::filesystem::directory_iterator();
                 ++iter)
             {
                 if (! boost::filesystem::is_regular_file(iter->path()))
                     continue;
                     
                 std::string file = iter->path().string();
                 m_files.push_back(file);
             }
             
             std::sort(m_files.begin(), m_files.end());
         }
     }
 }
コード例 #4
0
ファイル: ExceptionOperator.cpp プロジェクト: uboot/stromx
void ExceptionOperator::deinitialize()
{
    if(m_throwDeinitialize)
        throw OperatorError(*this, "Failed to deinitialize operator.");

    OperatorKernel::deinitialize();
}
コード例 #5
0
ファイル: ExceptionOperator.cpp プロジェクト: uboot/stromx
void ExceptionOperator::deactivate()
{
    if(m_throwDeactivate)
        throw OperatorError(*this, "Failed to deactivate operator.");

    OperatorKernel::deactivate();
}
コード例 #6
0
ファイル: ReadGpio.cpp プロジェクト: joccccc/stromx
 void ReadGpio::deactivate()
 {
     if (impl::GPIOUnexport(static_cast<int>(m_gpio)))
     {
         throw OperatorError(*this, 
             (boost::format("Failed to unexport GPIO %1%.") % m_gpio).str());
     }
 }
コード例 #7
0
ファイル: ExceptionOperator.cpp プロジェクト: joccccc/stromx
 void ExceptionOperator::execute(DataProvider& provider)
 {
     Id2DataPair input(INPUT);
     
     provider.receiveInputData(input);
     
     provider.sleep(100);
     
     if(m_throwExecute)
         throw OperatorError(*this, "Failed to execute operator.");
 }
コード例 #8
0
ファイル: Send.cpp プロジェクト: roteroktober/stromx
 void Send::activate()
 {
     try
     {
         m_server = new impl::Server(m_port);
     }
     catch(std::exception&)
     {
         throw OperatorError(*this, "Failed to start server.");
     }
     
 }
コード例 #9
0
ファイル: ReadGpio.cpp プロジェクト: joccccc/stromx
 void ReadGpio::execute(DataProvider& provider)
 {
     int value = impl::GPIORead(static_cast<int>(m_gpio));
     
     if (-1 == value)
     {
         throw OperatorError(*this, 
             (boost::format("Failed to read from GPIO %1%.") % m_gpio).str());
     }
     
     DataContainer data(new Bool(value));
     Id2DataPair output(OUTPUT, data);
     provider.sendOutputData(output);
 }
コード例 #10
0
ファイル: WriteGpio.cpp プロジェクト: joccccc/stromx
 void WriteGpio::execute(DataProvider& provider)
 {
     runtime::Id2DataPair input(INPUT);
     provider.receiveInputData(input);
     
     runtime::ReadAccess access(input.data());
     int value = access.get<runtime::Bool>();
     
     if (impl::GPIOWrite(static_cast<int>(m_gpio), value))
     {
         throw OperatorError(*this, 
             (boost::format("Failed to write to GPIO %1%.") % m_gpio).str());
     }
 }
コード例 #11
0
ファイル: ExceptionOperator.cpp プロジェクト: joccccc/stromx
 void ExceptionOperator::activate()
 {
     if(m_throwActivate)
         throw OperatorError(*this, "Failed to activate operator.");
 }  
コード例 #12
0
ファイル: ExceptionOperator.cpp プロジェクト: joccccc/stromx
 void ExceptionOperator::initialize()
 {
     if(m_throwInitialize)
         throw OperatorError(*this, "Failed to initialize operator.");
 }