int DATAPROCESS::ExtracSample(double *Lrawd, double *Rrawd, double *Lfiltd, double *Rfiltd, Throld throld, int len, BpNetdata *pb, Processdata *prod , int winlen) { //first process data. double *datasetL = new double[len]; double *datasetR = new double[len]; double *newdataL = new double[len]; double *newdataR = new double[len]; //BpNetdata data; Processdata psd; int Sampleblock = 0; for (int i = 0; i < len; i++) { if (i + winlen + 1 >= len) { psd = processdata(Lrawd + i, Rrawd + i, Lfiltd + i, Rfiltd + i, len - i - 1, throld); } else psd = processdata(Lrawd + i, Rrawd + i, Lfiltd + i, Rfiltd + i, winlen + 1, throld); datasetL[i] = psd.lmaxmin; datasetR[i] = psd.rmaxmin; newdataL[i] = psd.stdlval; newdataR[i] = psd.stdrval; } int smoothlen = 0; smooth(smoothlen, &newdataL, len); smooth(smoothlen, &newdataR, len); int distance = 0; for (int i = 0; i<len; i++) { if (newdataL[i]>0 || newdataR[i] > 0) distance++; else if (distance > 0) { pb[Sampleblock] = extractnetdata(datasetL + i - distance + 1, datasetR + i - distance + 1, distance, throld); pb[Sampleblock].sp = i - distance; pb[Sampleblock].ep = i; prod[Sampleblock].lmaxmin = prod[Sampleblock].rmaxmin = 0; prod[Sampleblock].stdlval = mean(newdataL + i - distance + 1, distance); prod[Sampleblock].stdrval = mean(datasetR + i - distance + 1, distance); Sampleblock++; distance = 0; } } delete newdataR; delete newdataL; delete datasetL; delete datasetR; return Sampleblock; }
int DATAPROCESS::ExtracProcessData(ManagedData &rawd, ManagedData& newd, ManagedData& out, const int sp, const int ep , int winlen , Throld t) { ManagedData rl, rr, nl, nr; rawd.GetAnydata(rl, 0); rawd.GetAnydata(rr, 1); newd.GetAnydata(nl, 0); newd.GetAnydata(nr, 1); int len = rl.GetDataSize(); Processdata psd; double *Lrawd = rl.GetData(); double *Rrawd = rr.GetData(); double *Lfiltd = nl.GetData(); double *Rfiltd = nr.GetData(); double *pd = new double[(ep - sp + 1) * 4]; for (int i = sp; i < ep + 1; i++) { if (i + winlen + 1 >= len) { continue; } psd = processdata(Lrawd + i, Rrawd + i, Lfiltd + i, Rfiltd + i, winlen + 1, t); pd[(i - sp) * 4] = psd.lmaxmin; pd[(i - sp) * 4 + 1] = psd.rmaxmin; pd[(i - sp) * 4 + 2] = psd.stdlval; pd[(i - sp) * 4 + 3] = psd.stdrval; } out.SetChannum(4); out.SetSampleRate(rawd.GetSampleRate()); out.SetData(pd, (ep - sp + 1) * 4); return ep - sp + 1; }
//------------------------------------------------------------------------------ int main(int argc, char** argv) { if(argc < 2) { std::cout << "usage: " << argv[0] << " <server URI> [process id]" << std::endl; std::cout << "Example: client \"tcp://logbroker:5555\" 27852\n"; std::cout << "To receive notifications from ALL processes omit the" " process id parameter\n"; return 0; } void* ctx = zmq_ctx_new(); void* publisher = zmq_socket(ctx, ZMQ_SUB); const char* brokerURI = argv[1]; const PID pid = argc > 2 ? atoi(argv[2]) : 0; int rc = zmq_connect(publisher, brokerURI); assert(rc == 0); rc = pid > 0 ? zmq_setsockopt(publisher, ZMQ_SUBSCRIBE, &pid, sizeof(pid)) : zmq_setsockopt(publisher, ZMQ_SUBSCRIBE, "", 0); assert(rc == 0); unsigned char buffer[0x100]; while(1) { rc = zmq_recv(publisher, buffer, 0x100, 0); assert(rc > 0); processdata(buffer, rc); } rc = zmq_close(publisher); assert(rc == 0); rc = zmq_ctx_destroy(ctx); assert(rc == 0); return 0; }
int screen::processData(const char* data,size_t length) { if (this->maxdatalength) { //Reallocate the buffer if needbe if (this->datalength+length+1 > this->maxdatalength) { this->maxdatalength=(this->datalength+length+1)*2; this->data=(char *)realloc(this->data,this->maxdatalength); } } else { //Allocate a new buffer this->maxdatalength=(length+1)*2; this->data=(char *)malloc(this->maxdatalength); this->data[0]=0; this->datalength=0; } //Reset the offset (we always start parsing from the start this->dataoffset=0; //Append the data memcpy(this->data+this->datalength,data,length); this->datalength+=length; //Process the data using the function in the class that extends this return processdata(); }
wxString PartitioningTreeCtrl::getCADData() { char a='"'; wxString tab=" "; wxString tabtab=" "; wxString value; wxTreeItemId root = GetRootItem(); wxTreeItemIdValue cookie; wxTreeItemId itemid = GetFirstChild(root,cookie); while (!(GetItemText(itemid).IsEmpty())) { if (GetType(itemid)==host) { value.Append(hostdata(itemid)); } if (GetType(itemid)==process) { value.Append(processdata(itemid)); } if (GetType(itemid)==home) { value.Append(homedata(itemid)); } itemid=GetNextChild(root,cookie); if (!itemid.IsOk()) { break; } } return value; }
void CCalcuteColor::ProcessData(ManagedData& rawdata, ManagedData& filtdata , ManagedData& colordata) { int winlen = m_Winlen; //分析窗口长 if (winlen <= 0) return; m_ColorData.SetData(0.0, rawdata.GetDataSize()); Processdata psd; //选取其中两个通道:0,and 1 rawdata.GetAnydata(m_pManagedata[0], 0); rawdata.GetAnydata(m_pManagedata[1], 1); filtdata.GetAnydata(m_pManagedata[3], 0); filtdata.GetAnydata(m_pManagedata[4], 1); COLORREF Curbite = NBite; int len = m_pManagedata[0].GetDataSize(); for (int i = 0; i < len;i++) { if (i + winlen + 1 >= len) //若分析窗口小于winlen,则标记为Curbite { m_ColorData[i * 2] = (double)Curbite; m_ColorData[i * 2 + 1] = (double)Curbite; continue; } /*对这段数据进行最大值减最小值以及标准差计算 若计算结果小于阈值(包括标准差小于阈值),则将这段数据中的标准差置为0 */ psd = processdata(m_pManagedata[0].GetData() + i, m_pManagedata[1].GetData() + i, m_pManagedata[2].GetData() + i, m_pManagedata[3].GetData() + i, winlen + 1, m_BiteThreshold); if (psd.lmaxmin >= m_BiteThreshold.voltvalue || psd.rmaxmin >= m_BiteThreshold.voltvalue) //大于阈值则判断为咬牙 { m_ColorData[i * 2] = (double)Bite; m_ColorData[i * 2 + 1] = (double)Bite; Curbite = Bite; } else { m_ColorData[i * 2] = (double)NBite; m_ColorData[i * 2 + 1] = (double)NBite; Curbite = NBite; } } int cnl = colordata.GetDataSize(); //更新color缓冲区颜色值 int crl = m_ColorData.GetDataSize(); for (int k = cnl - 1; k >= 0; k--) { colordata[k] = m_ColorData[crl - cnl + k]; } }
int aixcimsrvrunning(pid_t pid, const char* processName) { int i,count; struct procsinfo *proctable; proctable=processdata(&count); if (proctable==NULL) return -1; for (i=0;i<count;i++) if (!strcmp(proctable[i].pi_comm, processName) && \ proctable[i].pi_pid==pid) { free(proctable); return 0; } free(proctable); return -1; }
wxString PartitioningTreeCtrl::hostdata(wxTreeItemId itemid) { char a='"'; wxString tab=" "; wxString tabtab=" "; wxString value; ItemTyp ityp=GetItemInfo(itemid); value.Append(tabtab); value.Append("<hostcollocation>\n"); value.Append(tabtab); value.Append("<usagename>"); value.Append(ityp.usagename); value.Append("</usagename>\n"); wxTreeItemIdValue cookie; wxTreeItemId childid = GetFirstChild(itemid,cookie); while (!(GetItemText(childid).IsEmpty())) { if (GetType(childid)==home) { value.Append(homedata(childid)); } if (GetType(childid)==process) { value.Append(processdata(childid)); } childid=GetNextChild(itemid,cookie); if(!childid.IsOk()) { break; }; } value.Append(tabtab); value.Append("</hostcollocation>\n"); return value; }