コード例 #1
0
  void Subscription::PublishCallback(Services::SharedPtr server, const PublishResult result)
  {

    if (Debug){ std::cout << "Subscription | Suscription::PublishCallback called with " <<result.NotificationMessage.NotificationData.size() << " notifications " << std::endl; }
    for (const NotificationData& data: result.NotificationMessage.NotificationData )
    {
      if (data.Header.TypeId == ExpandedObjectId::DataChangeNotification)
      {
        if (Debug) { std::cout << "Subscription | Notification is of type DataChange\n"; }
        CallDataChangeCallback(data);
      }
      else if (data.Header.TypeId == ExpandedObjectId::EventNotificationList)
      {
        if (Debug) { std::cout << "Subscription | Notification is of type Event\n"; }
        CallEventCallback(data);
      }
      else if (data.Header.TypeId == ExpandedObjectId::StatusChangeNotification)
      {
        if (Debug) { std::cout << "Subscription | Notification is of type StatusChange\n"; }
        CallStatusChangeCallback(data);
      }
      else
      {
        std::cout << "Subscription | Error unknown notficiation type received: " << data.Header.TypeId <<std::endl;
      }
    }
    OpcUa::SubscriptionAcknowledgement ack;
    ack.SubscriptionId = GetId();
    ack.SequenceNumber = result.NotificationMessage.SequenceNumber;
    PublishRequest request;
    request.SubscriptionAcknowledgements.push_back(ack);
    server->Subscriptions()->Publish(request);
  }
コード例 #2
0
void finalizeComputestep1Local()
{
    /* Get the size of the serialized input */
    MPI_Bcast( &perNodeArchLength, sizeof(size_t), MPI_CHAR, mpiRoot, MPI_COMM_WORLD );

    byte *nodeResults = new byte[ perNodeArchLength ];

    /* Transfer partial results from the root node */

    MPI_Scatter(serializedData.get(), perNodeArchLength, MPI_CHAR, nodeResults, perNodeArchLength, MPI_CHAR, mpiRoot,
                MPI_COMM_WORLD);

    /* Deserialize partial results from step 2 */
    OutputDataArchive dataArch( nodeResults, perNodeArchLength );

    services::SharedPtr<data_management::DataCollection> dataFromStep2ForStep3 =
        services::SharedPtr<data_management::DataCollection>( new data_management::DataCollection() );
    dataFromStep2ForStep3->deserialize(dataArch);

    delete[] nodeResults;

    /* Create an algorithm to compute QR decomposition on the master node */
    qr::Distributed<step3Local> alg;

    alg.input.set( qr::inputOfStep3FromStep1, dataFromStep1ForStep3 );
    alg.input.set( qr::inputOfStep3FromStep2, dataFromStep2ForStep3 );

    /* Compute QR decomposition */
    alg.compute();
    alg.finalizeCompute();

    services::SharedPtr<qr::Result> res = alg.getResult();

    Qi = res->get(qr::matrixQ);
}
コード例 #3
0
void computeOnMasterNode()
{
    /* Create an algorithm to compute QR decomposition on the master node */
    qr::Distributed<step2Master> alg;

    for (size_t i = 0; i < nBlocks; i++)
    {
        /* Deserialize partial results from step 1 */
        OutputDataArchive dataArch( serializedData.get() + perNodeArchLength * i, perNodeArchLength );

        services::SharedPtr<data_management::DataCollection> dataForStep2FromStep1 =
            services::SharedPtr<data_management::DataCollection>( new data_management::DataCollection() );
        dataForStep2FromStep1->deserialize(dataArch);

        alg.input.add( qr::inputOfStep2FromStep1, i, dataForStep2FromStep1 );
    }

    /* Compute QR decomposition */
    alg.compute();

    services::SharedPtr<qr::DistributedPartialResult> pres = alg.getPartialResult();
    services::SharedPtr<KeyValueDataCollection> inputForStep3FromStep2 = pres->get( qr::outputOfStep2ForStep3 );

    for (size_t i = 0; i < nBlocks; i++)
    {
        /* Serialize partial results to transfer to local nodes for step 3 */
        InputDataArchive dataArch;
        (*inputForStep3FromStep2)[i]->serialize( dataArch );

        if( i == 0 )
        {
            perNodeArchLength = dataArch.getSizeOfArchive();
            /* Serialized data is of equal size for each node if it was equal in step 1 */
            serializedData = services::SharedPtr<byte>( new byte[ perNodeArchLength * nBlocks ] );
        }

        dataArch.copyArchiveToArray( serializedData.get() + perNodeArchLength * i, perNodeArchLength );
    }

    services::SharedPtr<qr::Result> res = alg.getResult();

    R = res->get(qr::matrixR);
}
コード例 #4
0
 Object::Object(NodeId objectId, Services::SharedPtr services)
   : Node(services)
 {
   Id = objectId;
   ReadParameters attrs;
   attrs.AttributesToRead.push_back(ToReadValueId(objectId, AttributeId::DisplayName));
   attrs.AttributesToRead.push_back(ToReadValueId(objectId, AttributeId::BrowseName));
   std::vector<DataValue> values = services->Attributes()->Read(attrs);
   DisplayName = values[0].Value.As<LocalizedText>();
   BrowseName = values[1].Value.As<QualifiedName>();
 }
コード例 #5
0
 Variable::Variable(NodeID variableID, Services::SharedPtr services)
   : Node(services)
 {
   Id = variableID;
   ReadParameters attrs;
   attrs.AttributesToRead.push_back(AttributeValueID(variableID, AttributeID::DISPLAY_NAME));
   attrs.AttributesToRead.push_back(AttributeValueID(variableID, AttributeID::BROWSE_NAME));
   attrs.AttributesToRead.push_back(AttributeValueID(variableID, AttributeID::DATA_TYPE));
   std::vector<DataValue> values = services->Attributes()->Read(attrs);
   DisplayName = values[0].Value.As<LocalizedText>();
   BrowseName = values[1].Value.As<QualifiedName>();
   DataType = OpcUa::DataTypeToVariantType(values[2].Value.As<NodeID>());
 }
コード例 #6
0
 Variable::Variable(NodeId variableId, Services::SharedPtr services)
   : Node(services)
 {
   Id = variableId;
   ReadParameters attrs;
   attrs.AttributesToRead.push_back(ToReadValueId(variableId, AttributeId::DisplayName));
   attrs.AttributesToRead.push_back(ToReadValueId(variableId, AttributeId::BrowseName));
   attrs.AttributesToRead.push_back(ToReadValueId(variableId, AttributeId::DataType));
   std::vector<DataValue> values = services->Attributes()->Read(attrs);
   DisplayName = values[0].Value.As<LocalizedText>();
   BrowseName = values[1].Value.As<QualifiedName>();
   DataType = OpcUa::DataTypeToVariantType(values[2].Value.As<NodeId>());
 }
コード例 #7
0
void computestep1Local()
{
    /* Initialize FileDataSource<CSVFeatureManager> to retrieve the input data from a .csv file */
    FileDataSource<CSVFeatureManager> dataSource(datasetFileNames[rankId], DataSource::doAllocateNumericTable,
                                                 DataSource::doDictionaryFromContext);

    /* Retrieve the input data */
    dataSource.loadDataBlock();

    /* Create an algorithm to compute QR decomposition on local nodes */
    qr::Distributed<step1Local> alg;

    alg.input.set( qr::data, dataSource.getNumericTable() );

    /* Compute QR decomposition */
    alg.compute();

    services::SharedPtr<data_management::DataCollection> dataFromStep1ForStep2;
    dataFromStep1ForStep2 = alg.getPartialResult()->get( qr::outputOfStep1ForStep2 );
    dataFromStep1ForStep3 = alg.getPartialResult()->get( qr::outputOfStep1ForStep3 );

    /* Serialize partial results required by step 2 */
    InputDataArchive dataArch;
    dataFromStep1ForStep2->serialize( dataArch );
    perNodeArchLength = dataArch.getSizeOfArchive();

    /* Serialized data is of equal size on each node if each node called compute() equal number of times */
    if (rankId == mpiRoot)
    {
        serializedData = services::SharedPtr<byte>( new byte[ perNodeArchLength * nBlocks ] );
    }

    byte *nodeResults = new byte[ perNodeArchLength ];
    dataArch.copyArchiveToArray( nodeResults, perNodeArchLength );

    /* Transfer partial results to step 2 on the root node */

    MPI_Gather( nodeResults, perNodeArchLength, MPI_CHAR, serializedData.get(), perNodeArchLength, MPI_CHAR, mpiRoot,
                MPI_COMM_WORLD);

    delete[] nodeResults;
}