pvbrowser manual
Back Content Forward

Modbus

In "qt designer" you can input the text properties tool_tip and whats_this. These properties are available within each mask and slot. Assume you have input the following strings in the tool_tip property within "qt designer".

 static const char *toolTip[] = {
 "",
 "",
 "Byte(0,0)",
 "Short(0,0)",
 "Bit(0,0)",
 "",
 ""};

Now you can use this slot to read Modbus values. You don't need to do manual programming for simple visualizations. Everything is specified within "qt designer". When you move over the datapoints in pvbrowser client the toolTip will be shown in a small popup window.

static int slotNullEvent(PARAM *p, DATA *d)
{
  if(p == NULL || d == NULL) return -1;
  int val,offset,number;

  for(int id=1; id<ID_END_OF_WIDGETS; id++)
  {
    if     (strncmp(toolTip[id],"Bit(",4)==0)
    {
      sscanf(toolTip[id],"Bit(%d,%d)",&offset,&number);
      val = modbus.readBit(offset,number);
      pvPrintf(p,id,"%d",val);
    }
    else if(strncmp(toolTip[id],"Byte(",5)==0)
    {
      sscanf(toolTip[id],"Byte(%d,%d)",&offset,&number);
      val = modbus.readByte(offset,number);
      pvPrintf(p,id,"%d",val);
    }
    else if(strncmp(toolTip[id],"Short(",6)==0)
    {
      sscanf(toolTip[id],"Short(%d,%d)",&offset,&number);
      val = modbus.readShort(offset,number);
      pvPrintf(p,id,"%d",val);
    }
  }
  return 0;
}
You have to include rlopcxmlda.h within pvapp.h

//***************************************************************************
//                          pvapp.h  -  description
//                             -------------------
//  begin            : Mo Aug 27 10:17:41 2007
//  generated by     : pvdevelop (C) 2000-2007 by Lehrig Software Engineering
//  email            : lehrig@t-online.de
//***************************************************************************
#ifndef _PVAPP_H_
#define _PVAPP_H_

#include "processviewserver.h"
#include "rlopcxmlda.h"
// todo: comment me out
//#include "rlmodbusclient.h"
//#include "rlsiemenstcpclient.h"
//#include "rlppiclient.h"
//#include "modbusdaemon.h"             // this is generated
//#include "siemensdaemon.h"            // this is generated
//#include "ppidaemon.h"                // this is generated

int show_mask1(PARAM *p);

#endif


Back Content Forward