- added support to use association specific data sets in reports

pull/6/head
Michael Zillgith 11 years ago
parent 2b1029d276
commit 47c5892dd1

@ -46,13 +46,6 @@ namespace report_new_dataset
{ {
con.Connect(hostname, 102); con.Connect(hostname, 102);
List<string> serverDirectory = con.GetServerDirectory(false);
foreach (string entry in serverDirectory)
{
Console.WriteLine("LD: " + entry);
}
// create a new data set // create a new data set
List<string> dataSetElements = new List<string>(); List<string> dataSetElements = new List<string>();
@ -62,7 +55,11 @@ namespace report_new_dataset
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn3.mag.f[MX]"); dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn3.mag.f[MX]");
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn4.mag.f[MX]"); dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn4.mag.f[MX]");
string dataSetReference = "simpleIOGenericIO/LLN0.ds1"; // permanent (domain specific) data set
//string dataSetReference = "simpleIOGenericIO/LLN0.ds1";
// temporary (association specific) data set
string dataSetReference = "@newds";
// Note: this function will throw an exception when a data set with the same name already exists // Note: this function will throw an exception when a data set with the same name already exists
con.CreateDataSet(dataSetReference, dataSetElements); con.CreateDataSet(dataSetReference, dataSetElements);
@ -98,7 +95,7 @@ namespace report_new_dataset
} }
// delete the data set // delete the data set
con.DeleteDataSet("simpleIOGenericIO/LLN0.ds1"); con.DeleteDataSet(dataSetReference);
con.Abort(); con.Abort();
} }

@ -80,6 +80,9 @@ MmsMapping_startEventWorkerThread(MmsMapping* self);
void void
MmsMapping_stopEventWorkerThread(MmsMapping* self); MmsMapping_stopEventWorkerThread(MmsMapping* self);
DataSet*
MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableList variableList);
void void
MmsMapping_triggerReportObservers(MmsMapping* self, MmsValue* value, ReportInclusionFlag flag); MmsMapping_triggerReportObservers(MmsMapping* self, MmsValue* value, ReportInclusionFlag flag);

@ -103,8 +103,11 @@ MmsGooseControlBlock_destroy(MmsGooseControlBlock self)
GLOBAL_FREEMEM(self->dataSetRef); GLOBAL_FREEMEM(self->dataSetRef);
if (self->dataSet != NULL) { if (self->dataSet != NULL) {
if (self->isDynamicDataSet) if (self->isDynamicDataSet) {
MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet); MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet);
self->isDynamicDataSet = false;
self->dataSet = NULL;
}
} }
MmsValue_delete(self->mmsValue); MmsValue_delete(self->mmsValue);
@ -168,8 +171,11 @@ MmsGooseControlBlock_enable(MmsGooseControlBlock self)
GLOBAL_FREEMEM(self->dataSetRef); GLOBAL_FREEMEM(self->dataSetRef);
if (self->dataSet != NULL) if (self->dataSet != NULL)
if (self->isDynamicDataSet) if (self->isDynamicDataSet) {
MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet); MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet);
self->isDynamicDataSet = false;
self->dataSet = NULL;
}
if (self->dataSetValues != NULL) { if (self->dataSetValues != NULL) {
LinkedList_destroyStatic(self->dataSetValues); LinkedList_destroyStatic(self->dataSetValues);

@ -2440,8 +2440,8 @@ MmsMapping_stopEventWorkerThread(MmsMapping* self)
} }
#endif /* (CONFIG_MMS_THREADLESS_STACK != 1) */ #endif /* (CONFIG_MMS_THREADLESS_STACK != 1) */
static DataSet* DataSet*
createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableList variableList) MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableList variableList)
{ {
DataSet* dataSet = (DataSet*) GLOBAL_MALLOC(sizeof(DataSet)); DataSet* dataSet = (DataSet*) GLOBAL_MALLOC(sizeof(DataSet));
@ -2520,7 +2520,7 @@ MmsMapping_getDomainSpecificDataSet(MmsMapping* self, char* dataSetName)
if (variableList == NULL) if (variableList == NULL)
return NULL; return NULL;
return createDataSetByNamedVariableList(self, variableList); return MmsMapping_createDataSetByNamedVariableList(self, variableList);
} }
void void

@ -141,10 +141,12 @@ deleteDataSetValuesShadowBuffer(ReportControl* self)
} }
GLOBAL_FREEMEM(self->bufferedDataSetValues); GLOBAL_FREEMEM(self->bufferedDataSetValues);
}
if (self->valueReferences != NULL) if (self->valueReferences != NULL)
GLOBAL_FREEMEM(self->valueReferences); GLOBAL_FREEMEM(self->valueReferences);
self->bufferedDataSetValues = NULL;
}
} }
void void
@ -165,8 +167,11 @@ ReportControl_destroy(ReportControl* self)
deleteDataSetValuesShadowBuffer(self); deleteDataSetValuesShadowBuffer(self);
if (self->isDynamicDataSet) { if (self->isDynamicDataSet) {
if (self->dataSet != NULL) if (self->dataSet != NULL) {
MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet); MmsMapping_freeDynamicallyCreatedDataSet(self->dataSet);
self->isDynamicDataSet = false;
self->dataSet = NULL;
}
} }
if (self->buffered) if (self->buffered)
@ -453,8 +458,10 @@ createDataSetValuesShadowBuffer(ReportControl* rc)
} }
static bool static bool
updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet) updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet, MmsServerConnection* connection)
{ {
bool success = false;
MmsValue* dataSetValue; MmsValue* dataSetValue;
if (newDatSet != NULL) if (newDatSet != NULL)
@ -465,8 +472,12 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet)
char* dataSetName = MmsValue_toString(dataSetValue); char* dataSetName = MmsValue_toString(dataSetValue);
if (rc->isDynamicDataSet) { if (rc->isDynamicDataSet) {
if (rc->dataSet != NULL) if (rc->dataSet != NULL) {
deleteDataSetValuesShadowBuffer(rc);
MmsMapping_freeDynamicallyCreatedDataSet(rc->dataSet); MmsMapping_freeDynamicallyCreatedDataSet(rc->dataSet);
rc->isDynamicDataSet = false;
rc->dataSet = NULL;
}
} }
if (dataSetValue != NULL) { if (dataSetValue != NULL) {
@ -475,8 +486,22 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet)
if (dataSet == NULL) { if (dataSet == NULL) {
dataSet = MmsMapping_getDomainSpecificDataSet(mapping, dataSetName); dataSet = MmsMapping_getDomainSpecificDataSet(mapping, dataSetName);
if (dataSet == NULL) {
/* check if association specific data set is requested */
if (dataSetName[0] == '@') {
if (connection != NULL) {
MmsNamedVariableList mmsVariableList
= MmsServerConnection_getNamedVariableList(connection, dataSetName + 1);
if (mmsVariableList != NULL)
dataSet = MmsMapping_createDataSetByNamedVariableList(mapping, mmsVariableList);
}
}
}
if (dataSet == NULL) if (dataSet == NULL)
return false; goto exit_function;
rc->isDynamicDataSet = true; rc->isDynamicDataSet = true;
@ -500,10 +525,12 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet)
rc->inclusionFlags = (ReportInclusionFlag*) GLOBAL_CALLOC(dataSet->elementCount, sizeof(ReportInclusionFlag)); rc->inclusionFlags = (ReportInclusionFlag*) GLOBAL_CALLOC(dataSet->elementCount, sizeof(ReportInclusionFlag));
return true; success = true;
goto exit_function;
} }
return false; exit_function:
return success;
} }
static char* static char*
@ -1156,7 +1183,7 @@ Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* eleme
printf("Activate report for client %s\n", printf("Activate report for client %s\n",
MmsServerConnection_getClientAddress(connection)); MmsServerConnection_getClientAddress(connection));
if (updateReportDataset(self, rc, NULL)) { if (updateReportDataset(self, rc, NULL, connection)) {
updateOwner(rc, connection); updateOwner(rc, connection);
@ -1254,7 +1281,7 @@ Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* eleme
if (!MmsValue_equals(datSet, value)) { if (!MmsValue_equals(datSet, value)) {
if (updateReportDataset(self, rc, value)) { if (updateReportDataset(self, rc, value, connection)) {
if (rc->buffered) if (rc->buffered)
purgeBuf(rc); purgeBuf(rc);
@ -2126,7 +2153,7 @@ Reporting_activateBufferedReports(MmsMapping* self)
ReportControl* rc = (ReportControl*) element->data; ReportControl* rc = (ReportControl*) element->data;
if (rc->buffered) { if (rc->buffered) {
if (updateReportDataset(self, rc, NULL)) if (updateReportDataset(self, rc, NULL, NULL))
rc->isBuffering = true; rc->isBuffering = true;
else else
rc->isBuffering = false; rc->isBuffering = false;

Loading…
Cancel
Save