*** empty log message ***

This commit is contained in:
cvs
2002-06-10 12:45:24 +00:00
parent 0daef05b2e
commit 267d16908a
20 changed files with 863 additions and 538 deletions

View File

@@ -443,61 +443,18 @@ void Load(Base *base, int from, int to, int stdStep) {
}
}
static char *encode=DATA_CODE;
int DataEncode(float *data, int dataSize, char *coded, int codedLen) {
int i, n, p, gap;
float minD, maxD, range;
if (dataSize >= (codedLen-26)/2) ERR_MSG("codedLen too small");
minD=DATA_UNDEF;
maxD=DATA_UNDEF;
for (i=0; i<dataSize; i++) {
if (data[i]!=DATA_UNDEF) {
if (maxD==DATA_UNDEF) {
maxD=data[i]; minD=data[i];
} else {
if (data[i] > maxD) maxD=data[i];
if (data[i] < minD) minD=data[i];
}
}
}
range = maxD - minD;
if (range == 0) range=1;
ERR_SI(p=sprintf(coded, "%d %5g %5g ", dataSize, minD, range));
gap=0;
for (i=0; i<dataSize; i++) {
if ( data[i] == DATA_UNDEF ) {
coded[p++]='/';
} else if ( data[i] == DATA_GAP ) {
coded[p++]='.';
} else {
n=( (data[i] - minD) * 4095 ) / range + 0.5;
assert(n>=0 && n <4096);
coded[p++]=encode[n % 64];
coded[p++]=encode[n / 64];
}
}
coded[p++]=',';
coded[p]='\0';
assert(p < codedLen);
return p;
OnError:
return -1;
}
int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep, char *coded, int codedLen) {
int DataGetMult(char *names, int startTime, int endTime, int step, int stdStep, float *data, int data_len) {
Base base;
Set *set, *s;
int stp, minStep, period, s1;
char *nams, nam[32];
int p, l, n, i, j, siz1, siz2, halfsiz, start;
float data[SET_LEN];
base.head = NULL;
period = endTime - startTime;
if (period<=0) period=1;
n=0; nams = names;
while (nams != NULL) {
while (nams != NULL) { /* count names */
nams = str_split(nam, nams, ' ');
if (nam[0] != '\0') n++;
}
@@ -505,7 +462,7 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
stp=step;
if (stp<stdStep) stp=stdStep;
nams=names;
while (nams!=NULL) {
while (nams!=NULL) { /* create sets for data not in memory */
nams=str_split(nam, nams, ' ');
if (nam[0]!='\0') {
set=FindSet(&database, nam);
@@ -520,12 +477,11 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
}
}
}
if (base.head != NULL) {
if (base.head != NULL) { /* load if needed */
Load(&base, startTime, endTime, stdStep);
}
p=0;
nams=names;
coded[0]='\0';
while (nams!=NULL) {
nams=str_split(nam, nams, ' ');
if (nam[0]!='\0') {
@@ -550,9 +506,8 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
}
}
}
if (s1 == 0) {
data[0]=DATA_UNDEF;
ERR_I(l=DataEncode(data, 1, coded+p, codedLen-p));
if (s1 == 0) { /* empty array */
data[p++]=0;
} else {
minStep = s->step;
stp = step;
@@ -560,40 +515,44 @@ int DataGetCoded(char *names, int startTime, int endTime, int step, int stdStep,
if (startTime + minStep * halfsiz * 2 > endTime) {
if (stp < minStep) stp = minStep;
halfsiz = period / (2 * stp) + 1;
if (halfsiz * 2 > SET_LEN) halfsiz = SET_LEN / 2;
if (halfsiz * 4 + 32 * n > codedLen) {
halfsiz = ((codedLen - p) / n - 32) / 4;
if (halfsiz * 2 + n > data_len) { /* check if enough space */
halfsiz = ((data_len - p) / n - 1) / 2;
}
}
siz1 = (s1 - startTime) * halfsiz / period * 2;
siz2 = halfsiz * 2 - siz1;
s1 = startTime + (siz1 * period + halfsiz) / halfsiz / 2;
p++;
if (siz1 > 0) {
halfsiz = (s1 - startTime) / set->step / 2;
if (halfsiz * 2 < siz1 && halfsiz > 0) {
ERR_I(GetSet(set, startTime, s1, halfsiz*2, data));
ERR_I(GetSet(set, startTime, s1, halfsiz*2, data+p));
j = siz1 - 1;
for (i = halfsiz * 2-1; i >= 0; i--) { /* expand data */
while (j > siz1 / 2 * i / halfsiz) {
data[j]=DATA_GAP; j--;
data[p+j]=DATA_GAP; j--;
}
data[j]=data[i]; j--;
data[p+j]=data[p+i]; j--;
}
} else {
ERR_I(GetSet(set, startTime, s1, siz1, data));
ERR_I(GetSet(set, startTime, s1, siz1, data+p));
}
l=siz1;
} else {
l=0;
}
if (siz2 > 0) {
ERR_I(GetSet(s, s1, endTime, siz2, data+siz1));
ERR_I(GetSet(s, s1, endTime, siz2, data+p+siz1));
l+=siz2;
}
ERR_I(l=DataEncode(data, siz1+siz2, coded+p, codedLen-p));
data[p-1]=l;
p+=l;
}
p+=l;
n--;
}
}
FreeBase(&base);
return (0);
return p;
OnError:
return(-1);
return -1;
}