/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/views.c

  • Committer: nicolas.zilio at hotmail
  • Date: 2015-09-15 18:11:02 UTC
  • mto: This revision was merged to the branch mainline in revision 307.
  • Revision ID: nicolas.zilio@hotmail.fr-20150915181102-e64mwgcm0e618xoy
bof....

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
 
139
139
  
140
140
  for(j=0;ctx->register_ctx[i].views[j].name;j++){
141
 
      if(!(strcasecmp("name",ctx->register_ctx[i].views[j].base_unit.name))){/*if we asked for the unit "name"*/
142
 
        err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,value/*the command name*/,0,&temp_value,value_size,NULL);
 
141
    if(!(strcasecmp("name",(char*)unit))){/*if we asked for the unit "name"*/
 
142
        err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,NULL/*the command name*/,0,&temp_value,value_size,value);
143
143
        if(err){
144
144
          pcilib_error("can't read from the register with the enum view");
145
145
          return PCILIB_ERROR_FAILED;
156
156
      }else{
157
157
        for(k=0;ctx->register_ctx[i].views[j].base_unit.transforms[k].name;k++){
158
158
          if(!(strcasecmp(ctx->register_ctx[i].views[j].base_unit.transforms[k].name,(char*)unit))){
 
159
            ctx->register_ctx[i].views[j].base_unit.transforms[k].name
159
160
            err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,(char*)unit, 0, &temp_value,0,&(ctx->register_ctx[i].views[j]));
 
161
            /***wrong***/         pcilib_view_apply_unit(ctx->register_ctx[i].views[j].base_unit.transforms[k].name,unit,(pcilib_register_value_t*)value);
160
162
            if(err){
161
163
              pcilib_error("can't write to the register with the formula view %s", unit);
162
164
              return PCILIB_ERROR_FAILED;
189
191
  }
190
192
 
191
193
  for(j=0;ctx->register_ctx[i].views[j].name;j++){
192
 
    if(!(strcasecmp(ctx->register_ctx[i].views[j].base_unit.name,"name"))){/*if we asked for the unit "name"*/
193
 
      err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,(char*)unit/*the command name*/,1,&temp_value,0,&(ctx->register_ctx[i].views[j]));
 
194
    if(!(strcasecmp((char*)unit,"name"))){/*if we asked for the unit "name"*/
 
195
      err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters,NULL,1,&temp_value,0,value);
194
196
      if(err){
195
197
        pcilib_error("can't write to the register with the enum view");
196
198
        return PCILIB_ERROR_FAILED;
209
211
    }else{
210
212
      for(k=0;ctx->register_ctx[i].views[j].base_unit.transforms[k].name;k++){
211
213
        if(!(strcasecmp(ctx->register_ctx[i].views[j].base_unit.transforms[k].name,(char*)unit))){
 
214
          pcilib_view_apply_unit(ctx->register_ctx[i].views[j].base_unit.transforms[k].name,unit,(pcilib_register_value_t*)value);
212
215
          err=ctx->register_ctx[i].views[j].op(ctx,ctx->register_ctx[i].views[j].parameters, (char*)unit, 1, &temp_value,0,&(ctx->register_ctx[i].views[j]));
213
216
          if(err){
214
217
            pcilib_error("can't write to the register with the formula view %s", unit);
237
240
 * always : viewval=view params=view params
238
241
 * write: name=enum command regval:the value corresponding to the command
239
242
 */
240
 
int operation_enum(pcilib_t *ctx, void *params, char* name, int view2reg, pcilib_register_value_t *regval, size_t viewval_size, void* viewval){
 
243
int operation_enum(pcilib_t *ctx, void *params, char* unit, int view2reg, pcilib_register_value_t *regval, size_t viewval_size, void* viewval){
241
244
  int j,k;
242
245
  if(view2reg==1){
243
246
    for(j=0; ((pcilib_enum_t*)(params))[j].name;j++){
244
 
      if(!(strcasecmp(((pcilib_enum_t*)(params))[j].name,name))){
 
247
      if(!(strcasecmp(((pcilib_enum_t*)(params))[j].name,(char*)viewval))){
245
248
        *regval=((pcilib_enum_t*)(params))[j].value;
246
249
        return 0;
247
250
      }
253
256
            pcilib_error("the string to contain the enum command is too tight");
254
257
            return PCILIB_ERROR_MEMORY;
255
258
          }
256
 
        strncpy(name,((pcilib_enum_t*)(params))[j].name, strlen(((pcilib_enum_t*)(params))[j].name));
 
259
        strncpy((char*)viewval,((pcilib_enum_t*)(params))[j].name, strlen(((pcilib_enum_t*)(params))[j].name));
257
260
        k=strlen(((pcilib_enum_t*)(params))[j].name);
258
 
        name[k]='\0';
 
261
        ((char*)viewval)[k]='\0';
259
262
        return 0;
260
263
      }
261
264
    }
293
296
          }
294
297
          strncpy(formula,((pcilib_formula_t*)params)->read_formula,strlen(((pcilib_formula_t*)params)->read_formula));
295
298
          pcilib_view_apply_formula(ctx,formula, regval);
296
 
          pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,regval);
 
299
          //      pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,regval);
297
300
          return 0;
298
301
        }
299
302
      }
310
313
          /* when we have found the correct view of type formula, we apply the formula, that get the good value for return*/
311
314
          formula=malloc(sizeof(char)*strlen(((pcilib_formula_t*)params)->write_formula));
312
315
          strncpy(formula,((pcilib_formula_t*)params)->write_formula,strlen((( pcilib_formula_t*)params)->write_formula));
313
 
          pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,&value);
 
316
          //pcilib_view_apply_unit(((pcilib_view_t*)viewval)->base_unit.transforms[j],unit,regval);
314
317
          pcilib_view_apply_formula(ctx,formula,regval);
315
318
          /* we maybe need some error checking there , like temp_value >min and <max*/
316
319
          return 0;