uploadPreparedValues()

The method uploads values from the internal data structure to MindSphere.

Synopsis

int uploadPreparedValues();

Return value

The method returns 0 when it was successfully executed. The method returns -1 when the data point was passed to the constructor and is not valid or the upload process fails. The method returns -2 when no values were prepared for the upload (see the method prepareValues()).

Description

The method uploads the prepared values in several steps. The method checks if it is executed in a redundant system and whether the system is the active system. If the system is the active one or the system is not a redundant system, the method checks if the asset has an ID. If an ID does not exist for the asset, an ID is created.

If an ID cannot be created (e.g. since the asset does not contain important information), the method is aborted and the method returns -1. If the method is not aborted, the method checks if the asset is connected to MindSphere. If it is not connected, the method establishes a connection. If the connection fails, the method is aborted and it returns -1.

If the method was not aborted, the values are transferred to MindSphere Server. If the upload is successful, the method returns 0, the internal mapping is cleared and can be used for the next upload. If the upload fails, the method returns -1 and the mapping is not cleared.

The connection and the ID are only checked when the method is called for the first time. When an upload was successful, the method tries to transfer the values when it is called. If the value size exceeds the maximum upload size (payload size), the upload is split into several parts. The parts are grouped by time stamp to maintain the data integrity.

When re-uploading a timestamp to the MindSphere Server, the previously uploaded timestamp and all values it contains will be deleted. This is a limitation of MindSphere and not of WinCC OA.

#uses "classes/mindSphere/MindSphereAsset"

void main()
{
  string dp = "NameOfMindSphereAsset";/* This MindSphere Asset must already exist in WinCC OA. */
  MindSphereAsset assetX = MindSphereAsset(dp);
  //shared_ptr can also be used
  //shared_ptr<MindSphereAsset> assetPtr = new MindSphereAsset(dp);
  dyn_int values1, values2;
  dyn_time times1, times2;
  string dpe1 = "validDPEName1"; //must be changed to a real DPE with archived values
  string dpe2 = "validDPEName2"; //must be changed to a real DPE with archived values
  string msDp1 = "MindSphereDatapointName1";
  string msDp2 = "MindSphereDatapointName2";
  dpGetPeriod(getCurrentTime()-1000, getCurrentTime(), 0, dpe1, values1, times1, dpe2, values2, times2);
  assetX.prepareValues(msDp1, values1, times1);
  assetX.prepareValues(msDp2, values2, times2);
  int err = assetX.uploadPreparedValues();
  DebugTN(err);
  //assetPtr.prepareValues(msDp1, values1, times1);
  //assetPtr.prepareValues(msDp2, values2, times2);
  //int errPtr = assetPtr.uploadPreparedValues();
  //DebugTN(errPtr);
}

Assignment

MindSphere

Availability

UI, CTRL