Commit aaf2e162 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master'

parents d67a0b0c 076449e5
This diff is collapsed.
...@@ -64,5 +64,7 @@ void CompCurvePolValueFo_exec( ...@@ -64,5 +64,7 @@ void CompCurvePolValueFo_exec(
plc_sThread* tp, pwr_sClass_CompCurvePolValueFo* o); plc_sThread* tp, pwr_sClass_CompCurvePolValueFo* o);
void CompMPC_Fo_init(pwr_sClass_CompMPC_Fo* o); void CompMPC_Fo_init(pwr_sClass_CompMPC_Fo* o);
void CompMPC_Fo_exec(plc_sThread* tp, pwr_sClass_CompMPC_Fo* o); void CompMPC_Fo_exec(plc_sThread* tp, pwr_sClass_CompMPC_Fo* o);
void CompMPC_MLP_Fo_init(pwr_sClass_CompMPC_MLP_Fo* o);
void CompMPC_MLP_Fo_exec(plc_sThread* tp, pwr_sClass_CompMPC_MLP_Fo* o);
#endif #endif
This diff is collapsed.
This diff is collapsed.
...@@ -986,9 +986,9 @@ public class GdhWebSocketServer ...@@ -986,9 +986,9 @@ public class GdhWebSocketServer
i += 4; i += 4;
int elements = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int elements = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 4; i += 2;
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
attrName = checkAttrName( attrName); attrName = checkAttrName( attrName);
if ( attrName != null) { if ( attrName != null) {
Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements); Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements);
...@@ -1093,9 +1093,9 @@ public class GdhWebSocketServer ...@@ -1093,9 +1093,9 @@ public class GdhWebSocketServer
i += 4; i += 4;
int elements = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int elements = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24);
i += 4; i += 4;
int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8) + ((value[i+2] & 0xFF) << 16) + ((value[i+3] & 0xFF) << 24); int nameSize = ((value[i] & 0xFF) << 0) + ((value[i+1] & 0xFF) << 8);
i += 4; i += 2;
String attrName = new String( value, i, nameSize); String attrName = new String( value, i, nameSize);
attrName = checkAttrName( attrName); attrName = checkAttrName( attrName);
if ( attrName != null) { if ( attrName != null) {
Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements); Sub ret = this.refObjectInfo(attrName, threadNumber, refId, elements);
......
This diff is collapsed.
...@@ -873,7 +873,7 @@ int main(int argc, char* argv[]) ...@@ -873,7 +873,7 @@ int main(int argc, char* argv[])
time_since_keepalive = 0; time_since_keepalive = 0;
} }
if (time_since_rcv >= rn_tcp->LinkTimeout && feqf(rn_tcp->LinkTimeout, 0.0f)) { if (time_since_rcv >= rn_tcp->LinkTimeout && !feqf(rn_tcp->LinkTimeout, 0.0f)) {
if (rn_tcp->LinkUp) { if (rn_tcp->LinkUp) {
errh_Info("TCP link down %s", rn_tcp->RemoteHostname); errh_Info("TCP link down %s", rn_tcp->RemoteHostname);
rn_tcp->LinkUp = 0; rn_tcp->LinkUp = 0;
......
...@@ -574,6 +574,13 @@ int sev_server::mainloop() ...@@ -574,6 +574,13 @@ int sev_server::mainloop()
garbage_collector(0); garbage_collector(0);
time_Aadd(&next_garco, &next_garco, &garco_interval); time_Aadd(&next_garco, &next_garco, &garco_interval);
} }
if (sts == QCOM__ALLOCQUOTA) {
struct timespec r, t;
t.tv_sec = 0;
t.tv_nsec = tmo * 1000000;
nanosleep(&t, &r);
continue;
}
if (sts == QCOM__TMO || !mp) if (sts == QCOM__TMO || !mp)
continue; continue;
...@@ -965,6 +972,7 @@ int sev_server::send_histdata( ...@@ -965,6 +972,7 @@ int sev_server::send_histdata(
qcom_sQid tgt, sev_sMsgHistDataGetRequest* rmsg, unsigned int size) qcom_sQid tgt, sev_sMsgHistDataGetRequest* rmsg, unsigned int size)
{ {
pthread_t thread; pthread_t thread;
pthread_attr_t attr;
int sts; int sts;
sev_sHistDataThread* arg = (sev_sHistDataThread*)malloc(sizeof(*arg)); sev_sHistDataThread* arg = (sev_sHistDataThread*)malloc(sizeof(*arg));
...@@ -974,8 +982,11 @@ int sev_server::send_histdata( ...@@ -974,8 +982,11 @@ int sev_server::send_histdata(
arg->size = size; arg->size = size;
if (m_read_threads) { if (m_read_threads) {
printf("New read thread\n"); static int pcnt = 0;
sts = pthread_create(&thread, NULL, send_histdata_thread, arg); printf("New read thread %d\n", pcnt++);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sts = pthread_create(&thread, &attr, send_histdata_thread, arg);
if (sts != 0) if (sts != 0)
printf("pthread_create error %d\n", sts); printf("pthread_create error %d\n", sts);
} else { } else {
...@@ -1062,11 +1073,13 @@ void* sev_server::send_histdata_thread(void* arg) ...@@ -1062,11 +1073,13 @@ void* sev_server::send_histdata_thread(void* arg)
if (!qcom_Put(&sts, &tgt, &put)) { if (!qcom_Put(&sts, &tgt, &put)) {
qcom_Free(&sts, put.data); qcom_Free(&sts, put.data);
} }
free(tbuf);
free(vbuf);
if (sev->m_read_threads) if (sev->m_read_threads)
sev->m_db->delete_thread(thread); sev->m_db->delete_thread(thread);
// pthread_exit( (void *) 1); pthread_exit( (void *) 1);
return (void*)1; return (void*)1;
} }
......
This diff is collapsed.
...@@ -639,6 +639,7 @@ MYSQL* sev_dbms_env::open_thread(unsigned int* sts) ...@@ -639,6 +639,7 @@ MYSQL* sev_dbms_env::open_thread(unsigned int* sts)
void sev_dbms_env::close_thread(MYSQL* con) void sev_dbms_env::close_thread(MYSQL* con)
{ {
mysql_close(con); mysql_close(con);
mysql_thread_end();
} }
bool sev_dbms_env::exists() bool sev_dbms_env::exists()
...@@ -1956,6 +1957,10 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid, ...@@ -1956,6 +1957,10 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid,
char where_part[200]; char where_part[200];
int rows = 0; int rows = 0;
MYSQL* con; MYSQL* con;
char startval[8];
char endval[8];
char *startvalue = 0;
char *endvalue = 0;
if (thread) if (thread)
con = (MYSQL*)thread; con = (MYSQL*)thread;
...@@ -2009,23 +2014,47 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid, ...@@ -2009,23 +2014,47 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid,
unsigned int endid; unsigned int endid;
if (starttime) { if (starttime) {
// Get id for starttime if (type == pwr_eType_Boolean) {
*sts = get_closest_time( // Get id for starttime
thread, item.tablename, item.options, starttime, 1, &startid); *sts = get_closest_time(
if (*sts == SEV__NOROWS) thread, item.tablename, item.options, starttime, 1, &startid);
get_id_range(sts, thread, &item, item.options, &startid, 0); if (*sts == SEV__NOROWS)
get_id_range(sts, thread, &item, item.options, &startid, 0);
get_id_value(thread, item.tablename, startid, type, size,
startval);
startvalue = startval;
} else {
// Get id for starttime
*sts = get_closest_time(
thread, item.tablename, item.options, starttime, 1, &startid);
if (*sts == SEV__NOROWS)
get_id_range(sts, thread, &item, item.options, &startid, 0);
}
} else { } else {
get_id_range(sts, thread, &item, item.options, &startid, 0); get_id_range(sts, thread, &item, item.options, &startid, 0);
// startid = 0; // startid = 0;
} }
if (endtime) { if (endtime) {
// Get id for starttime if (type == pwr_eType_Boolean) {
*sts = get_closest_time( // Get id for starttime
thread, item.tablename, item.options, endtime, 0, &endid); *sts = get_closest_time(
if (*sts == SEV__NOROWS) thread, item.tablename, item.options, endtime, 1, &endid);
get_id_range(sts, thread, &item, item.options, 0, &endid); if (*sts == SEV__NOROWS)
if (endid == 0) get_id_range(sts, thread, &item, item.options, 0, &endid);
endid = strtoul(row[4], 0, 10); if (endid == 0)
endid = strtoul(row[4], 0, 10);
get_id_value(thread, item.tablename, endid, type, size, endval);
endvalue = endval;
} else {
// Get id for starttime
*sts = get_closest_time(
thread, item.tablename, item.options, endtime, 0, &endid);
if (*sts == SEV__NOROWS)
get_id_range(sts, thread, &item, item.options, 0, &endid);
if (endid == 0)
endid = strtoul(row[4], 0, 10);
}
} else } else
endid = strtoul(row[4], 0, 10); endid = strtoul(row[4], 0, 10);
...@@ -2312,13 +2341,20 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid, ...@@ -2312,13 +2341,20 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid,
} else } else
break; break;
} }
int bufrows = rows; int bufrows = rows + (startvalue != 0) + (endvalue != 0);
if (options & pwr_mSevOptionsMask_ReadOptimized) { if (options & pwr_mSevOptionsMask_ReadOptimized) {
*tbuf = (pwr_tTime*)calloc(bufrows, sizeof(pwr_tTime)); *tbuf = (pwr_tTime*)calloc(bufrows, sizeof(pwr_tTime));
*vbuf = calloc(bufrows, size); *vbuf = calloc(bufrows, size);
int bcnt = 0; int bcnt = 0;
if (startvalue) {
(*tbuf)[bcnt] = *starttime;
memcpy((*vbuf), startvalue, size);
bcnt++;
}
for (int i = 0; i < rows; i++) { for (int i = 0; i < rows; i++) {
int j = 0; int j = 0;
...@@ -2384,6 +2420,13 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid, ...@@ -2384,6 +2420,13 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid,
// else // else
// printf( "%5d %5d %s %s\n", i, bcnt, row[0], row[1]); // printf( "%5d %5d %s %s\n", i, bcnt, row[0], row[1]);
} }
if (endvalue) {
(*tbuf)[bcnt] = *endtime;
memcpy(((char*)*vbuf) + bcnt * size, endvalue, size);
bcnt++;
}
printf("bcnt %d bufrows %d\n", bcnt, bufrows); printf("bcnt %d bufrows %d\n", bcnt, bufrows);
*bsize = bcnt; *bsize = bcnt;
mysql_free_result(result); mysql_free_result(result);
...@@ -3999,6 +4042,48 @@ int sev_dbms::get_closest_time(void* thread, char* tablename, ...@@ -3999,6 +4042,48 @@ int sev_dbms::get_closest_time(void* thread, char* tablename,
return 1; return 1;
} }
int sev_dbms::get_id_value(void* thread, char* tablename,
unsigned int id, pwr_eType type, int size,
void *value)
{
char query[200];
MYSQL* con;
if (thread)
con = (MYSQL*)thread;
else
con = m_env->con();
sprintf(query, "select value from %s where id = %d",
tablename, id);
int rc = mysql_query(con, query);
if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf("%s Query Error\n", __FUNCTION__);
return SEV__DBERROR;
}
MYSQL_ROW row;
MYSQL_RES* result = mysql_store_result(con);
if (!result) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf("%s Status Result Error\n", __FUNCTION__);
return SEV__DBERROR;
}
row = mysql_fetch_row(result);
if (!row) {
mysql_free_result(result);
return SEV__NOROWS;
} else
cdh_StringToAttrValue(type, row[0], value);
mysql_free_result(result);
return 1;
}
int sev_dbms::get_objectvalues(pwr_tStatus* sts, void* thread, sev_item* item, int sev_dbms::get_objectvalues(pwr_tStatus* sts, void* thread, sev_item* item,
unsigned int size, pwr_tTime* starttime, pwr_tTime* endtime, int maxsize, unsigned int size, pwr_tTime* starttime, pwr_tTime* endtime, int maxsize,
pwr_tTime** tbuf, void** vbuf, unsigned int* bsize) pwr_tTime** tbuf, void** vbuf, unsigned int* bsize)
......
...@@ -216,6 +216,9 @@ public: ...@@ -216,6 +216,9 @@ public:
void delete_thread(void* thread); void delete_thread(void* thread);
int get_closest_time(void* thread, char* tablename, unsigned int options, int get_closest_time(void* thread, char* tablename, unsigned int options,
pwr_tTime* time, int before, unsigned int* id); pwr_tTime* time, int before, unsigned int* id);
int get_id_value(void* thread, char* tablename,
unsigned int id, pwr_eType type, int size,
void *value);
void string_to_mysqlstring(char* in, char* out, int size); void string_to_mysqlstring(char* in, char* out, int size);
void mysqlstring_to_string(char* in, char* out, int size); void mysqlstring_to_string(char* in, char* out, int size);
int get_id_range(pwr_tStatus* sts, void* thread, sev_item* item, int get_id_range(pwr_tStatus* sts, void* thread, sev_item* item,
......
<topic> __DocumentTitlePage
<image> pwr_logga_doc.png
<h1> Multivariate analysis
<hr>
2019-05-28
Version 5.7.0
<hr>
</topic>
<topic> __DocumentInfoPage
Copyright 2005-2019 SSAB EMEA AB
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
</topic>
<option> printdisable
<topic> index
Multivariate Analysis
<image> pwr_logga.gif
<h1>Multivariate Analysis
Introduction <link> mva_introduction
Fetch data <link> mva_get_data
Linear Regression Model <link> mva_linreg_model
Index <index>
</topic>
<option> printenable
<chapter>
<topic> mva_introduction
Introduction
ProviewR Multivariate Analyses is utilities to analyse data stored or generated by a
ProviewR system.
</topic>
</chapter>
<chapter>
<topic> mva_get_data
Get data
<h1>Get data
Data can be fetch from an Sev server or read from a csv file generated for example by
the Xtt logging function.
<option> printdisable
<b>Fetch from sev <link>mva_fetch_from_sev
<b>Xtt logging <link>mva_xtt_logging
<option> printenable
</topic>
<headerlevel>
<topic> mva_fetch_from_sev
Fetch data from Sev
...
</topic>
<topic> mva_xtt_logging
Xtt logging
...
</topic>
</headerlevel>
</chapter>
<chapter>
<topic> mva_linreg_model
Linear Regression Model
<h1>Create Model
<option> printdisable
<b>Create model <link>mva_create_model
<b>Apply model <link>mva_apply_model
<option> printenable
</topic>
<headerlevel>
<topic> mva_create_model
Create model
...
</topic>
<topic> mva_apply_model
Apply model
...
</topic>
</headerlevel>
</chapter>
...@@ -35,9 +35,9 @@ silent : ...@@ -35,9 +35,9 @@ silent :
.SUFFIXES: .SUFFIXES:
$(exe_dir)/pwrrt.so : pwrrtmodule.c $(exe_dir)/pwrrt.so : pwrrtmodule.c
@ if [ $(PWRE_CONF_PYDEV) -eq 1 ]; then\ @ if [ "$(PWRE_CONF_PYDEV)" == "1" ]; then\
echo "Bulding Python c extension pwrrt";\ echo "Bulding Python c extension pwrrt";\
python setup_pwrrt.py -q build --build-base $(bld_dir);\ python setup_pwrrt.py build --build-base $(bld_dir);\
if [ "$(pwre_hw)" == "hw_x86_64" ]; then \ if [ "$(pwre_hw)" == "hw_x86_64" ]; then \
mv $(bld_dir)/lib.linux-x86_64-2.7/pwrrt.so $(pwr_exe); \ mv $(bld_dir)/lib.linux-x86_64-2.7/pwrrt.so $(pwr_exe); \
elif [ "$(pwre_hw)" == "hw_x86" ]; then \ elif [ "$(pwre_hw)" == "hw_x86" ]; then \
......
...@@ -3011,7 +3011,7 @@ Appl_mainloop(ApplObject *self, PyObject *args) ...@@ -3011,7 +3011,7 @@ Appl_mainloop(ApplObject *self, PyObject *args)
int swap = 0; int swap = 0;
int first_scan = 1; int first_scan = 1;
arglist = Py_BuildValue("(O)", self->ctx); arglist = Py_BuildValue("()", self->ctx);
PyEval_CallObject(self->open, arglist); PyEval_CallObject(self->open, arglist);
...@@ -3491,6 +3491,8 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3491,6 +3491,8 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
char *server, *fromstr, *tostr; char *server, *fromstr, *tostr;
pwr_tOName *oidvect; pwr_tOName *oidvect;
pwr_tOName *anamevect; pwr_tOName *anamevect;
pwr_tOName cond_oid;
pwr_tOName cond_aname;
int *isobjectvect; int *isobjectvect;
int oidcnt, anamecnt, isobjectcnt; int oidcnt, anamecnt, isobjectcnt;
pwr_tTime from, to; pwr_tTime from, to;
...@@ -3501,6 +3503,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3501,6 +3503,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
PyObject *oidobj, *anameobj, *isobjectobj; PyObject *oidobj, *anameobj, *isobjectobj;
pwr_tFloat32 *vbuf; pwr_tFloat32 *vbuf;
int maxrows = 0; int maxrows = 0;
int options = 0;
int rows; int rows;
pwr_eType vtype; pwr_eType vtype;
unsigned int vsize; unsigned int vsize;
...@@ -3513,7 +3516,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3513,7 +3516,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
int valcnt; int valcnt;
pwr_tDeltaTime dt; pwr_tDeltaTime dt;
pwr_tFloat32 **vvect; pwr_tFloat32 **vvect;
float *tbuf; float *tbuf;
if ( !pwrrt_scctx) { if ( !pwrrt_scctx) {
sevcli_init( &sts, &pwrrt_scctx); sevcli_init( &sts, &pwrrt_scctx);
...@@ -3521,8 +3524,8 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3521,8 +3524,8 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
return set_error(sts); return set_error(sts);
} }
if ( !PyArg_ParseTuple(args, "sOOOssf|Is", &server, &oidobj, &anameobj, &isobjectobj, if ( !PyArg_ParseTuple(args, "sOOOssf|IsI", &server, &oidobj, &anameobj, &isobjectobj,
&fromstr, &tostr, &tdiff, &maxrows, &time_format)) &fromstr, &tostr, &tdiff, &maxrows, &time_format, &options))
return NULL; return NULL;
if ( time_format) { if ( time_format) {
...@@ -3554,8 +3557,6 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3554,8 +3557,6 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
if ( EVEN(sts)) if ( EVEN(sts))
return set_error(sts); return set_error(sts);
} }
time_Adiff(&dt, &to, &from);
valcnt = (int)time_DToFloat(NULL, &dt)/tdiff;
if ( PyTuple_Check(oidobj)) if ( PyTuple_Check(oidobj))
oidcnt = PyTuple_Size(oidobj); oidcnt = PyTuple_Size(oidobj);
...@@ -3611,8 +3612,79 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3611,8 +3612,79 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
isobjectvect[i] = PyInt_AsLong(pystr); isobjectvect[i] = PyInt_AsLong(pystr);
} }
for ( i = 0; i < oidcnt; i++) if (options & 1) {
printf("arg %s.%s\n", oidvect[i], anamevect[i]); /* First objid is condition */
strcpy(cond_oid, oidvect[0]);
strcpy(cond_aname, anamevect[0]);
for (i = 0; i < oidcnt - 1; i++) {
strcpy(oidvect[i], oidvect[i+1]);
strcpy(anamevect[i], anamevect[i+1]);
isobjectvect[i] = isobjectvect[i+1];
}
oidcnt -= 1;
anamecnt -= 1;
isobjectcnt -= 1;
if (oidcnt <= 0)
return set_error(GDH__ARGCOUNT);
/* Get condition data */
if ( strncmp("_O", cond_oid, 2) == 0)
sts = cdh_StringToObjid(cond_oid, &oid);
else
sts = gdh_NameToObjid(cond_oid, &oid);
if ( EVEN(sts))
return set_error(sts);
sevcli_get_itemdata( &sts, pwrrt_scctx, oid, cond_aname, from, to, maxrows, &ttbuf,
(void **)&vbuf, &rows, &vtype, &vsize);
if ( sts == SEV__NOPOINTS)
Py_RETURN_NONE;
else if (EVEN(sts))
return set_error(sts);
//for (i = 0; i < rows; i++) {
// char timstr[40];
// time_AtoAscii(&ttbuf[i], time_eFormat_DateAndTime, timstr, sizeof(timstr));
// printf("%d %s %d\n", i, timstr, ((pwr_tBoolean *)vbuf)[i]);
//}
/* Find longest continuous interval where condition is high */
pwr_tBoolean last_value = 0;
pwr_tFloat32 max_time = 0.0f;
int last_idx;
int start_idx;
int end_idx;
for (i = 0; i < rows; i++) {
if (((pwr_tBoolean *)vbuf)[i] == 1 && last_value == 0) {
last_value = 1;
last_idx = i;
}
else if ((((pwr_tBoolean *)vbuf)[i] == 0 && last_value == 1) ||
(((pwr_tBoolean *)vbuf)[i] == 1 && last_value == 1 && i == rows - 1)) {
last_value = 0;
time_Adiff(&dt, &ttbuf[i], &ttbuf[last_idx]);
if (time_DToFloat(0, &dt) > max_time) {
max_time = time_DToFloat(0, &dt);
start_idx = last_idx;
end_idx = i;
}
}
}
if (max_time > 0.0f) {
from = ttbuf[start_idx];
to = ttbuf[end_idx];
}
free(ttbuf);
free(vbuf);
}
time_Adiff(&dt, &to, &from);
valcnt = (int)time_DToFloat(NULL, &dt)/tdiff;
//for ( i = 0; i < oidcnt; i++)
// printf("arg %s.%s\n", oidvect[i], anamevect[i]);
vvect = calloc(oidcnt, sizeof(float *)); vvect = calloc(oidcnt, sizeof(float *));
...@@ -3624,7 +3696,6 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3624,7 +3696,6 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
if ( EVEN(sts)) if ( EVEN(sts))
return set_error(sts); return set_error(sts);
if (!isobjectvect[i]) { if (!isobjectvect[i]) {
sevcli_get_itemdata( &sts, pwrrt_scctx, oid, anamevect[i], from, to, maxrows, &ttbuf, sevcli_get_itemdata( &sts, pwrrt_scctx, oid, anamevect[i], from, to, maxrows, &ttbuf,
(void **)&vbuf, &rows, &vtype, &vsize); (void **)&vbuf, &rows, &vtype, &vsize);
...@@ -3633,7 +3704,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3633,7 +3704,7 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
else if (EVEN(sts)) else if (EVEN(sts))
return set_error(sts); return set_error(sts);
/* Create data rows for panda with interpolation */ /* Create data rows for pandas with interpolation */
tbuf = malloc(rows * sizeof(float)); tbuf = malloc(rows * sizeof(float));
for ( j = 0; j < rows; j++) { for ( j = 0; j < rows; j++) {
...@@ -3646,10 +3717,10 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3646,10 +3717,10 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
for ( j = 0; j < valcnt; j++) { for ( j = 0; j < valcnt; j++) {
if ( j*tdiff < tbuf[0]) if ( j*tdiff < tbuf[0])
vvect[i][j] = vbuf[0]; vvect[i][j] = vbuf[0];
else if ( j*tdiff > tbuf[rows - 1]) else if ( j*tdiff >= tbuf[rows - 1])
vvect[i][j] = vbuf[rows-1]; vvect[i][j] = vbuf[rows-1];
else { else {
while( tbuf[k] <= j*tdiff) while( tbuf[k] <= j*tdiff && k < rows - 1)
k++; k++;
vvect[i][j] = vbuf[k-1] + (vbuf[k] - vbuf[k-1])/(tbuf[k] - tbuf[k-1]) * (j*tdiff - tbuf[k-1]); vvect[i][j] = vbuf[k-1] + (vbuf[k] - vbuf[k-1])/(tbuf[k] - tbuf[k-1]) * (j*tdiff - tbuf[k-1]);
} }
...@@ -3701,12 +3772,12 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args) ...@@ -3701,12 +3772,12 @@ static PyObject *pwrrt_getSevItemsDataFrame(PyObject *self, PyObject *args)
vp1 = (float *)(((char*)vbuf) + lineoffs); vp1 = (float *)(((char*)vbuf) + lineoffs);
vvect[l][j] = *vp1; vvect[l][j] = *vp1;
} }
else if ( j*tdiff > tbuf[rows - 1]) { else if ( j*tdiff >=tbuf[rows - 1]) {
vp1 = (float *)(((char*)vbuf) + (rows - 1)*linesize + lineoffs); vp1 = (float *)(((char*)vbuf) + (rows - 1)*linesize + lineoffs);
vvect[l][j] = *vp1; vvect[l][j] = *vp1;
} }
else { else {
while( tbuf[k] <= j*tdiff) while( tbuf[k] <= j*tdiff && k < rows)
k++; k++;
vp1 = (float *)(((char *)vbuf) + (k - 1)*linesize + lineoffs); vp1 = (float *)(((char *)vbuf) + (k - 1)*linesize + lineoffs);
vp2 = (float *)(((char *)vp1) + linesize); vp2 = (float *)(((char *)vp1) + linesize);
...@@ -4109,6 +4180,8 @@ PyMODINIT_FUNC initpwrrt(void) ...@@ -4109,6 +4180,8 @@ PyMODINIT_FUNC initpwrrt(void)
Py_INCREF(&ApplType); Py_INCREF(&ApplType);
PyModule_AddObject(m, "Appl", (PyObject *)&ApplType); PyModule_AddObject(m, "Appl", (PyObject *)&ApplType);
PyModule_AddIntConstant(m, "FRAME_OPTIONS_CONDITION", 1);
PyDateTime_IMPORT; PyDateTime_IMPORT;
gdh_Init("Python"); gdh_Init("Python");
......
include $(pwre_dir_symbols)
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/variables.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/rules.mk
endif
vpath %.py $(co_source)
source_dirs := $(co_source)
py_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.py) \
), $(notdir $(file)) \
) \
)
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
export_py := $(patsubst %.py, $(exe_dir)/%.py, $(py_sources))
export_png := $(patsubst %.png, $(exe_dir)/%.png, $(png_sources))
clean_py := $(patsubst %.py, clean_%.py, $(py_sources))
clean_png := $(patsubst %.png, clean_%.png, $(png_sources))
.PHONY : all init copy lib exe clean realclean\
$(clean_py)
all : init copy | silent
init : silent
copy : $(export_py) $(export_png) | silent
lib : silent
exe : silent
clean :
realclean : clean $(clean_py) $(clean_png)
silent :
@ :
$(export_py) : $(exe_dir)/%.py : %.py
@ echo "Exporting $< ..."
@ $(cp) $(cpflags) $(source) $(target)
$(export_png) : $(exe_dir)/%.png : %.png
@ echo "Exporting $< ..."
@ $(cp) $(cpflags) $(source) $(target)
$(clean_py) : clean_%.py : %.py
@ rm $(exe_dir)/$*.py
$(clean_png) : clean_%.png : %.png
@ rm $(exe_dir)/$*.png
#
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
#
import pwrrt
import datetime
class DSup:
"""DSup class, handling of a DSupComp object.
"""
def __init__(self, name):
self.name = name
a = pwrrt.attribute(self.name + '.DetectCheck')
if a.value():
self.active = False
else:
self.active = True
def setDetect(self):
"""Set alarm detect."""
a = pwrrt.attribute(self.name + '.DetectCheck')
if a.value():
a = pwrrt.attribute(self.name + '.DetectTime')
a.setValue(datetime.datetime.now().strftime('%d-%b-%Y %H:%M:%S'))
a = pwrrt.attribute(self.name + '.DetectSend')
a.setValue(1)
a = pwrrt.attribute(self.name + '.DetectCheck')
a.setValue(0)
a = pwrrt.attribute(self.name + '.ReturnCheck')
a.setValue(1)
self.active = True
def setReturn(self):
"""Set alarm return."""
a = pwrrt.attribute(self.name + '.ReturnCheck')
if a.value():
a = pwrrt.attribute(self.name + '.ReturnTime')
a.setValue(datetime.datetime.now().strftime('%d-%b-%Y %H:%M:%S'))
a = pwrrt.attribute(self.name + '.ReturnSend')
a.setValue(1)
a = pwrrt.attribute(self.name + '.ReturnCheck')
a.setValue(0)
a = pwrrt.attribute(self.name + '.DetectCheck')
a.setValue(1)
self.active = False
#!/usr/bin/python
#
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
#
# Maintenance supervision server
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
from scipy.interpolate import interp1d
import sys
import math
import time
import datetime
import getopt
import os
import pwrrt
import co
import rt
from rt_mva import *
from rt_mva_msg import *
class SupObj:
def __init__(self, sup):
global scantime
self.sup = sup
self.name = sup.name()
self.sts = 0
self.limitsts = [None] * 10
aname = sup.fullName() + '.ScanTime'
a = pwrrt.attribute(aname)
self.scantime = a.value()
self.cnt = 0
self.interval = self.scantime/scantime
self.dsup = []
i = 0
while i < 10:
dsup = rt.DSup(sup.fullName() + '.Limits[' + str(i) + '].Sup')
self.dsup.append(dsup)
i += 1
def setSts(self, sts):
if self.sts != sts:
self.sts = sts
a = pwrrt.attribute(self.sup.fullName() + '.Status')
a.setValue(sts)
def evenSts(self):
return (self.sts & 1) == 0
def oddSts(self):
return (self.sts & 1) != 0
def setLimitSts(self, idx, sts):
if self.limitsts[idx] != sts:
self.limitsts[idx] = sts
a = pwrrt.attribute(self.sup.fullName() + '.Limits[' + str(idx) + '].Status')
a.setValue(sts)
#
# Open function, backcall from application
#
def open_cb():
global olist
pwrrt.login('pwrp', 'pwrp')
olist = []
cid = pwrrt.Cid('LinRegSup')
for attr in cid.attrObjects():
o = SupObj(attr)
olist.append(o)
o.setSts(MVA__NORMAL)
#
# Close function, backcall from application
#
def close_cb():
print 'Closing down'
#
# Scan function, backcall from application
#
def scan_cb():
global olist
for o in olist:
if o.cnt < o.interval:
o.cnt += 1
continue
o.cnt = 0
process(o)
#
# Handling of a LinRegSup object
#
def process(o):
if o.evenSts() and o.sts != MVA__STDLOW and o.sts != MVA__SCORELOW and \
o.sts != MVA__SERVERTIMEOUT and o.sts != MVA__SERVERREAD:
return
a = pwrrt.attribute(o.sup.fullName() + '.Server')
server = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.FormulaFile')
formulafile = co.translateFilename(a.value())
a = pwrrt.attribute(o.sup.fullName() + '.MeasuringTime')
measuringtime = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.PointInterval')
pointinterval = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.MaxNoOfPoints')
maxnoofpoints = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.StdDeviationMinLimit')
stdmin = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.ScoreMinLimit')
scoremin = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.CondAttr')
condattr = a.value().strip()
i = 0
options = 0
dataoid = []
dataattr = []
dataname = []
origcol = ['Time']
datacol = []
isobject = []
# If condition attribute, insert attribute first in list
if condattr != '':
options = pwrrt.FRAME_OPTIONS_CONDITION
idx = condattr.find('.')
dataoid.append(condattr[:idx])
dataattr.append(condattr[idx+1:])
isobject.append(False)
# Insert other attributes
while i < 10:
a = pwrrt.attribute(o.sup.fullName() + '.Attributes[' + str(i) + ']')
attr = a.value().strip()
if attr == '':
break;
idx = attr.find('.')
dataname.append(attr)
origcol.append(attr)
dataoid.append(attr[:idx])
dataattr.append(attr[idx+1:])
datacol.append('A' + str(i+1))
isobject.append(False)
i += 1
# Fetch data from server
try:
result = pwrrt.getSevItemsDataFrame( server, dataoid, dataattr, isobject,
measuringtime, 'now', pointinterval, maxnoofpoints, '-', options)
except RuntimeError as e:
print str(e), e
if str(e) == '%QCOM-E-TMO, time out':
o.setSts(MVA__SERVERTIMEOUT)
else:
o.setSts(MVA__SERVERREAD)
return
if result == None:
o.setSts(MVA__NODATA)
return
sts = MVA__NORMAL
origdata = pd.DataFrame(data=result)
origdata.columns = origcol
wf = WData()
wf.set_data(origdata, datacol, dataname)
# Check standard deviation
if stdmin > 0:
std = wf.wd[datacol[0]].std()
a = pwrrt.attribute(o.sup.fullName() + '.CurrentStdDeviation')
a.setValue(std)
if std < stdmin:
o.setSts(MVA__STDLOW)
a = pwrrt.attribute(o.sup.fullName() + '.CurrentScore')
a.setValue(0.0)
return
try:
wf.apply_formula(formulafile)
except co.Error as e:
o.setSts(e.status)
return
# Fit linear regression model
slr = LinearRegression()
reg = slr.fit(wf.wd.iloc[:,1:], wf.wd.iloc[:,0:1])
#print "coef ", slr.coef_
#print "intercept ", slr.intercept_
# Check score
if scoremin > 0:
pred = slr.predict(wf.wd.iloc[:,1:])
score = r2_score(pred, wf.wd.iloc[:,0:1])
a = pwrrt.attribute(o.sup.fullName() + '.CurrentScore')
a.setValue(score)
if score < scoremin:
sts = MVA__SCORELOW
if (sts & 1) != 0:
a = pwrrt.attribute(o.sup.fullName() + '.LastScan')
a.setValue(datetime.datetime.now().strftime('%d-%b-%Y %H:%M:%S'))
# Check coefficient limits
i = 0
while i < len(slr.coef_[0]):
a = pwrrt.attribute(o.sup.fullName() + '.Limits[' + str(i) + '].InitCoef')
initcoef = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.Limits[' + str(i) + '].LastCoef')
a.setValue(slr.coef_[0][i])
a = pwrrt.attribute(o.sup.fullName() + '.Limits[' + str(i) + '].Deviation')
a.setValue(slr.coef_[0][i] - initcoef)
a = pwrrt.attribute(o.sup.fullName() + '.Limits[' + str(i) + '].MinLimit')
minlimit = a.value()
a = pwrrt.attribute(o.sup.fullName() + '.Limits[' + str(i) + '].MaxLimit')
maxlimit = a.value()
if (sts & 1) != 0:
if slr.coef_[0][i] >= maxlimit or slr.coef_[0][i] <= minlimit:
o.setLimitSts(i, MVA__COEFLIMIT)
if not o.dsup[i].active:
o.dsup[i].setDetect()
else:
o.setLimitSts(i, MVA__COEF)
if o.dsup[i].active:
o.dsup[i].setReturn()
i += 1
o.setSts(sts)
# Get server object
cid = pwrrt.Cid('MaintSupServer')
server = None
for o in cid.objects():
server = o
break
if server == None:
exit()
a = o.attribute('ScanTime')
scantime = a.value()
# Create application
a = pwrrt.application('MaintSupServer',o.fullName(), 29, scantime,
open_cb, scan_cb, close_cb, None)
a.mainloop()
This diff is collapsed.
...@@ -117,6 +117,7 @@ typedef enum { ...@@ -117,6 +117,7 @@ typedef enum {
errh_eAnix_videomgm = 26, errh_eAnix_videomgm = 26,
errh_eAnix_redcom = 27, errh_eAnix_redcom = 27,
errh_eAnix_websocketserver = 28, errh_eAnix_websocketserver = 28,
errh_eAnix_maintsupserver = 29,
errh_eAnix_plc1 = 41, errh_eAnix_plc1 = 41,
errh_eAnix_plc2 = 42, errh_eAnix_plc2 = 42,
errh_eAnix_plc3 = 43, errh_eAnix_plc3 = 43,
......
...@@ -729,7 +729,7 @@ pwr_tBoolean ndc_ConvertNativeToRemoteData(pwr_tStatus* sts, ...@@ -729,7 +729,7 @@ pwr_tBoolean ndc_ConvertNativeToRemoteData(pwr_tStatus* sts,
for (tcount = cap->elem, scount = ap->elem; tcount > 0 && *size > 0; for (tcount = cap->elem, scount = ap->elem; tcount > 0 && *size > 0;
tcount--, scount--) { tcount--, scount--) {
if (scount > 0) { if (scount > 0) {
ndc_ConvertRemoteToNativeData(sts, lccp, ridx, nap, rarp, narp, ndc_ConvertNativeToRemoteData(sts, lccp, ridx, nap, rarp, narp,
tp, sp, size, (offset - cap->offs) % (cap->size / cap->elem), tp, sp, size, (offset - cap->offs) % (cap->size / cap->elem),
toffs + atoffs, soffs + asoffs, nid); toffs + atoffs, soffs + asoffs, nid);
asoffs += ap->size / ap->elem; asoffs += ap->size / ap->elem;
......
!
! ProviewR Open Source Process Control.
! Copyright (C) 2005-2019 SSAB EMEA AB.
!
! This file is part of ProviewR.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ProviewR. If not, see <http://www.gnu.org/licenses/>
!
! Linking ProviewR statically or dynamically with other modules is
! making a combined work based on ProviewR. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! ProviewR give you permission to, from the build function in the
! ProviewR Configurator, combine ProviewR with modules generated by the
! ProviewR PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of ProviewR (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
.facility MVA,28 /prefix = MVA__ !
success <successful completion> /succ
normal <Normal operating state> /info
nodata <No data received in requested interval> /info
nofrm <Formula file not found> /error
coeflimit <Coefficient limit exceeded> /error
coef <Coefficient in range> /info
stdlow <Low value of standard deviation> /error
scorelow <Low value of score> /error
servertimeout <Server timeout> /error
serverread <Error when reading data from server> /error
...@@ -74,4 +74,6 @@ ioread <IO stalled, io read error> /fatal ...@@ -74,4 +74,6 @@ ioread <IO stalled, io read error> /fatal
iowrite <IO stalled, io write error> /fatal iowrite <IO stalled, io write error> /fatal
reduinit <Redundancy init error> /error reduinit <Redundancy init error> /error
reduconfig <Redundancy not configured> /error reduconfig <Redundancy not configured> /error
filesyntax <Syntax error in file> /error
file <No such file> /error
.end .end
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
25 SEV 25 SEV
26 SIM 26 SIM
27 REDU 27 REDU
28 MVA
50 HD 50 HD
100 CDH 100 CDH
101 NDC 101 NDC
......
...@@ -16,11 +16,11 @@ endif ...@@ -16,11 +16,11 @@ endif
$(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg $(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg
@ $(log_msg_h) @ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h @ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h $(exe_dir)/$(tname).py
$(obj_dir)/%.cmsg $(inc_dir)/%.h : %.msg $(obj_dir)/%.cmsg $(inc_dir)/%.h : %.msg
@ $(log_msg_h) @ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(obj_dir)/$(tname).cmsg $(inc_dir)/$(tname).h @ $(tools_msg2cmsg) $(source) $(obj_dir)/$(tname).cmsg $(inc_dir)/$(tname).h $(exe_dir)/$(tname).py
$(obj_dir)/%.o : $(obj_dir)/%.cmsg $(obj_dir)/%.o : $(obj_dir)/%.cmsg
@ $(log_cmsg_obj) @ $(log_cmsg_obj)
......
...@@ -219,7 +219,7 @@ static void lex(FILE* fp) { ...@@ -219,7 +219,7 @@ static void lex(FILE* fp) {
} }
} }
static void WriteFiles(char* fname, FILE* cfp, FILE* hfp) static void WriteFiles(char* fname, FILE* cfp, FILE* hfp, FILE *pfp)
{ {
struct LstHead * fl; struct LstHead * fl;
struct LstHead * ml; struct LstHead * ml;
...@@ -255,6 +255,8 @@ static void WriteFiles(char* fname, FILE* cfp, FILE* hfp) ...@@ -255,6 +255,8 @@ static void WriteFiles(char* fname, FILE* cfp, FILE* hfp)
msg = facid + 0x8000 + (idx << 3) + LstEntry(ml, sMsgCB, MsgL)->Severity; msg = facid + 0x8000 + (idx << 3) + LstEntry(ml, sMsgCB, MsgL)->Severity;
snprintf(name, sizeof(name), "%s%s", prefix, LstEntry(ml, sMsgCB, MsgL)->m.MsgName); snprintf(name, sizeof(name), "%s%s", prefix, LstEntry(ml, sMsgCB, MsgL)->m.MsgName);
fprintf(hfp, "#define %-29s %9.9d /* x%08x */\n", name, msg, msg); fprintf(hfp, "#define %-29s %9.9d /* x%08x */\n", name, msg, msg);
if (pfp)
fprintf(pfp, "%s = %d\n", name, msg);
fprintf(cfp, "\t{\"%s\", \"%s\"}", LstEntry(ml, sMsgCB, MsgL)->m.MsgName, fprintf(cfp, "\t{\"%s\", \"%s\"}", LstEntry(ml, sMsgCB, MsgL)->m.MsgName,
LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt); LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt);
idx++; idx++;
...@@ -275,10 +277,11 @@ int main(int argc, char** argv) ...@@ -275,10 +277,11 @@ int main(int argc, char** argv)
{ {
FILE* cfp = NULL; FILE* cfp = NULL;
FILE* hfp = NULL; FILE* hfp = NULL;
FILE* pfp = NULL;
FILE* in = NULL; FILE* in = NULL;
if (argc != 4) { if (!(argc == 4 || argc == 5)) {
printf("Usage: co_msg2cmsg msg-file c_msg-file h_file\n"); printf("Usage: co_msg2cmsg msg-file c_msg-file h-file [py-file]\n");
exit(2); exit(2);
} }
...@@ -301,6 +304,16 @@ int main(int argc, char** argv) ...@@ -301,6 +304,16 @@ int main(int argc, char** argv)
exit(2); exit(2);
} }
if (argc >= 5) {
if (!(pfp = fopen(argv[4], "w"))) {
printf("Can't open python-output file: %s\n", argv[4]);
fclose(in);
fclose(cfp);
fclose(hfp);
exit(2);
}
}
LstInit(&lFacH); LstInit(&lFacH);
lex(in); lex(in);
...@@ -314,11 +327,13 @@ int main(int argc, char** argv) ...@@ -314,11 +327,13 @@ int main(int argc, char** argv)
if ((p = strchr(fname, '.'))) if ((p = strchr(fname, '.')))
*p = '\0'; *p = '\0';
WriteFiles(fname, cfp, hfp); WriteFiles(fname, cfp, hfp, pfp);
fclose(in); fclose(in);
fclose(cfp); fclose(cfp);
fclose(hfp); fclose(hfp);
if (pfp)
fclose(pfp);
return 0; return 0;
} }
!
! ProviewR Open Source Process Control.
! Copyright (C) 2005-2019 SSAB EMEA AB.
!
! This file is part of ProviewR.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ProviewR. If not, see <http://www.gnu.org/licenses/>
!
! Linking ProviewR statically or dynamically with other modules is
! making a combined work based on ProviewR. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! ProviewR give you permission to, from the build function in the
! ProviewR Configurator, combine ProviewR with modules generated by the
! ProviewR PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of ProviewR (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_a_linregsuplimit.wb_load -- Internal limit class for LinRegSup.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Supervision,NodeConfiguration
! @Summary
! Internal limit class for LinRegSup.
!
! @b See Also
! @classlink LinRegSup pwrb_linregsup.html
!*/
Object LinRegSupLimit $ClassDef 712
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "LinRegSupLimit"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Disable limit supervision.
!*/
Object Disable $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Initial coefficient value.
!*/
Object InitCoef $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Last coefficient value.
!*/
Object LastCoef $Attribute 4
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Deviation of last value from initial value.
!*/
Object Deviation $Attribute 5
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Mininum limit.
! If the last coefficient value is below the MinLimit,
! an alarm message is sent.
!*/
Object MinLimit $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Maximum limit.
! If the last coefficient value exceeds the MaxLimit,
! an alarm message is sent.
!*/
Object MaxLimit $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Min coefficient value for display.
!*/
Object MinShow $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Max coefficient value for display.
!*/
Object MaxShow $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Number of decimals of coefficient value in display.
!*/
Object NoOfDecimals $Attribute 10
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Current status of the limit check.
!*/
Object Status $Attribute 11
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
!/**
! DSupComp object for alarm message.
!*/
Object Sup $Attribute 12
Body SysBody
Attr Flags |= PWR_MASK_CLASS
Attr TypeRef = "pwrb:Class-DSupComp"
EndBody
EndObject
EndObject
Object Template LinRegSupLimit
Body RtBody
EndBody
EndObject
EndObject
EndSObject
This diff is collapsed.
!
! ProviewR Open Source Process Control.
! Copyright (C) 2005-2019 SSAB EMEA AB.
!
! This file is part of ProviewR.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ProviewR. If not, see <http://www.gnu.org/licenses/>
!
! Linking ProviewR statically or dynamically with other modules is
! making a combined work based on ProviewR. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! ProviewR give you permission to, from the build function in the
! ProviewR Configurator, combine ProviewR with modules generated by the
! ProviewR PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of ProviewR (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_maintsupserver.wb_load -- Maintainence supervision server.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Supervision,NodeConfiguration
! @Summary Mantainence supervision server.
! Maintainence supervision server.
!
! @b See Also
! @classlink LinRegSup pwrb_linregsup.html
!*/
Object MaintSupServer $ClassDef 714
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "MaintSupServer"
EndBody
Object Description $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object ScanTime $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
EndObject
Object Template MaintSupServer
Body RtBody
Attr ScanTime = 2.000000e+00
EndBody
EndObject
EndObject
EndSObject
...@@ -137,6 +137,7 @@ palette NavigatorPalette ...@@ -137,6 +137,7 @@ palette NavigatorPalette
class CompModeImc class CompModeImc
class CompModePID class CompModePID
class CompMPC class CompMPC
class CompMPC_MLP
class CompOnOffBurner class CompOnOffBurner
class CompOnOffZone class CompOnOffZone
class CompPosit class CompPosit
...@@ -1264,6 +1265,7 @@ palette PlcEditorPalette ...@@ -1264,6 +1265,7 @@ palette PlcEditorPalette
class CompModePID_Fo class CompModePID_Fo
class CompPID_Fo class CompPID_Fo
class CompMPC_Fo class CompMPC_Fo
class CompMPC_MLP_Fo
class CompModeImc_Fo class CompModeImc_Fo
class CompImc_Fo class CompImc_Fo
class CompOnOffBurnerFo class CompOnOffBurnerFo
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "pwr_version.h"
#include "co_string.h" #include "co_string.h"
#include "co_time.h" #include "co_time.h"
...@@ -194,6 +195,12 @@ void wb_print_wbl::printVolume(wb_volume& v, bool recursive) ...@@ -194,6 +195,12 @@ void wb_print_wbl::printVolume(wb_volume& v, bool recursive)
return; return;
} }
char timstr[40];
time_AtoAscii(0, time_eFormat_DateAndTime, timstr, sizeof(timstr));
indent() << "! Generated by wb_print_wbl " << timstr << "\n";
indent() << "! Volume " << v.name() << " \n";
indent() << "! Version " pwrv_cPwrVersionStr "\n";
wb_object o = v.object(); wb_object o = v.object();
const char* cname = v.cdef(v.cid()).name(); const char* cname = v.cdef(v.cid()).name();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -248,7 +248,7 @@ CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title, ...@@ -248,7 +248,7 @@ CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title,
name_p += textsize; name_p += textsize;
} }
list->header()->hide(); list->header()->close();
connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this,
SLOT(list_row_activated_cb(QTreeWidgetItem*, int))); SLOT(list_row_activated_cb(QTreeWidgetItem*, int)));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -200,10 +200,8 @@ public: ...@@ -200,10 +200,8 @@ public:
*/ */
void set_value(double value) void set_value(double value)
{ {
if (!feq(bar_value, value)) {
ctx->set_dirty();
}
bar_value = value; bar_value = value;
ctx->set_dirty();
} }
//! Moves object to alignment line or point. //! Moves object to alignment line or point.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment