예제 #1
0
static pwr_tStatus AoRangeToCoef( 
  io_sChannel 	*chanp)
{
  pwr_sClass_ChanAo	*cop;
  char			buf[120];
  pwr_tStatus		sts;
  pwr_tFloat32		PolyCoef1;
  pwr_tFloat32		PolyCoef0;

  cop = chanp->cop;

  if ( cop)
  {
    cop->CalculateNewCoef = 0;

    /* Coef for ActualValue to RawValue conversion */
    if ( cop->ActValRangeHigh != cop->ActValRangeLow)
    {
      cop->SigValPolyCoef1 = (cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow)/
		(cop->ActValRangeHigh - cop->ActValRangeLow);
      cop->SigValPolyCoef0 = cop->SensorSigValRangeHigh - cop->ActValRangeHigh *
		cop->SigValPolyCoef1;
    }
    else
    {
      sts = gdh_AttrrefToName( &chanp->ChanAref, buf, sizeof(buf), 
			cdh_mName_volumeStrict);
      if ( EVEN(sts)) return sts;
      errh_Error( "Invalid ActValueRange in Ao channel %s", buf);
      return IO__CHANRANGE;
    }
    /* Coef for ActualValue to SignalValue conversion */
    if ( cop->ChannelSigValRangeHigh != 0)
    {
      PolyCoef0 = 0;
      PolyCoef1 = cop->RawValRangeHigh / cop->ChannelSigValRangeHigh;
      cop->OutPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
      cop->OutPolyCoef0 = PolyCoef0 + PolyCoef1*
		cop->SigValPolyCoef0;
    }
    else
    {
      sts = gdh_AttrrefToName( &chanp->ChanAref, buf, sizeof(buf), 
			cdh_mName_volumeStrict);
      if ( EVEN(sts)) return sts;
      errh_Error( "Invalid SigValueRange in Ao channel %s", buf);
      return IO__CHANRANGE;
    }
  }
  return IO__SUCCESS;
}
예제 #2
0
void XttMethodToolbarGtk::activate_button(GtkWidget* w, gpointer data)
{
  XttMethodToolbarGtk* mt = ((xtt_sMethodButtonCb*)data)->mt;
  int idx = ((xtt_sMethodButtonCb*)data)->idx;

  int sts = 0;
  int is_attr;
  pwr_sAttrRef aref;
  pwr_tAName aname;
  pwr_tCmd cmd;
  xmenu_eItemType menu_type;

  if (mt->get_select_cb)
    sts = (mt->get_select_cb)(mt->m_parent_ctx, &aref, &is_attr);

  if (ODD(sts)) {
    if (aref.Flags.b.Object)
      menu_type = xmenu_eItemType_Object;
    else if (aref.Flags.b.ObjectAttr)
      menu_type = xmenu_eItemType_AttrObject;
    else
      menu_type = xmenu_eItemType_Attribute;

    sts = gdh_AttrrefToName(
        &aref, aname, sizeof(aname), cdh_mName_volumeStrict);
    if (idx < 32)
      sprintf(cmd, "call method/function=%s/object=%s",
          GeMethods::op_method[idx], aname);
    else
      sprintf(cmd, "call method/function=%s/object=%s",
          GeMethods::mnt_method[idx - 32], aname);

    mt->m_xnav->command(cmd);
  }
}
예제 #3
0
int rtt_crossref_channel(unsigned long ctx, pwr_tObjid objid, void* arg1,
    void* arg2, void* arg3, void* arg4)
{
  pwr_tAName hiername;
  int sts;
  pwr_sAttrRef signal_aref;

  sts = gdh_ObjidToName(objid, hiername, sizeof(hiername), cdh_mNName);
  if (EVEN(sts)) {
    rtt_message('E', "Cross reference not defined");
    return RTT__NOPICTURE;
  }
  strcat(hiername, ".SigChanCon");
  sts = gdh_GetObjectInfo(
      hiername, (pwr_tAddress)&signal_aref, sizeof(signal_aref));
  if (EVEN(sts))
    return sts;

  sts = gdh_AttrrefToName(&signal_aref, hiername, sizeof(hiername), cdh_mNName);
  if (EVEN(sts)) {
    rtt_message('E', "Cross reference not defined");
    return RTT__NOPICTURE;
  }

  sts = rtt_crr_signal(NULL, hiername);
  return sts;
}
예제 #4
0
void XCrrGtk::print()
{
  pwr_tStatus sts;
  pwr_tAName   	title;

  sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
  if ( EVEN(sts)) return;

  CoWowGtk::CreateBrowPrintDialogGtk( title, xcrrnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
				      (void *)toplevel, &sts);
}
예제 #5
0
int print_data( pwr_sAttrRef *arp, FILE *fp)
{
  int		sts;
  char		*s;
  pwr_tClassId	classid;
  char		*object_p;
  pwr_tAName   	dataname;
  pwr_tAName   	objectname;
  pwr_tAName   	attributename;
  pwr_tObjid	objid;
  int 		object_backup;
  int		array_element = 0;
  int		index;
  int		nr;

  sts = gdh_AttrrefToName( arp, dataname, sizeof(dataname), cdh_mNName);
  if ( EVEN(sts)) return sts;

  strcpy( objectname, dataname);
  if ( (s = strchr( objectname, '.'))) {
    *s = 0;
    object_backup = 0;
    strcpy( attributename, dataname);
    if ( (s = strchr( dataname, '['))) {
      array_element = 1;

      nr = sscanf( s+1, "%d", &index);
      if ( nr != 1) return 0;
    }
  }
  else {
    object_backup = 1;
  }

  sts = gdh_NameToObjid( objectname, &objid);
  if ( EVEN(sts)) return sts;

  sts = gdh_ObjidToPointer( objid, (void **)&object_p);
  if ( EVEN(sts)) return sts;

  sts = gdh_GetObjectClass( objid, &classid);
  if ( EVEN(sts)) return sts;

  if ( object_backup) {
    print_object( objid, classid, object_p, 0, objectname, fp);
  }
  else {
    print_attribute( objid, classid, object_p, attributename, array_element, index, fp);
  }
  return 1;
}
예제 #6
0
pwr_tStatus bck_print( char *filename)
{
  char fname[256];
  pwr_sAttrRef aref;
  pwr_tAName objname;
  FILE *fp = 0;
  pwr_sAttrRef dataname;
  int sts;

  if ( filename) {
    dcli_translate_filename( fname, filename);
    fp = fopen( fname, "w");
    if ( !fp) return 0;
  }

  sts = gdh_Init("pwr_bck_print");
  if (EVEN(sts)) return sts;

  sts = gdh_GetClassListAttrRef( pwr_cClass_Backup, &aref);
  while ( ODD(sts)) {
    if ( aref.Objid.vid < cdh_cUserVolMin) {
      // In template plc, continue
      sts = gdh_GetNextAttrRef( pwr_cClass_Backup, &aref, &aref);
      continue;
    }


    sts = gdh_AttrrefToName( &aref, objname, sizeof(objname), cdh_mName_volumeStrict); 
    if ( EVEN(sts)) return sts;

    if ( fp)
      fprintf( fp, "// %s\n", objname);
    else
      printf( "// %s\n", objname);

    strcat( objname, ".DataName");
    sts = gdh_GetObjectInfo( objname, &dataname, sizeof(dataname));

    sts = print_data( &dataname, fp);
    if ( EVEN(sts)) error_msg( sts, fp);
    
    sts = gdh_GetNextAttrRef( pwr_cClass_Backup, &aref, &aref);
  }

  if ( fp)
    fclose(fp);	     

  return 1;
}
예제 #7
0
파일: xtt_op.cpp 프로젝트: Strongc/proview
int Op::appl_action( int idx)
{
  pwr_tCmd cmd;
  pwr_tAName name;
  int sts;

  if ( command_cb) {
    sts = gdh_AttrrefToName( &button_aref[idx], name, sizeof(name), cdh_mName_volumeStrict);
    strcpy( cmd, "ope gra/obj=");
    strcat( cmd, name);

    command_cb( parent_ctx, cmd);
  }
  return XNAV__SUCCESS;
}
예제 #8
0
static pwr_tStatus InvertOn(xmenu_sMenuCall* ip)
{
  pwr_tAName name;
  pwr_tStatus sts;
  pwr_tCmd cmd;

  sts = gdh_AttrrefToName(&ip->Pointed, name, sizeof(name), cdh_mNName);
  if (EVEN(sts))
    return sts;

  snprintf(cmd, sizeof(cmd), "set sig inv/on/name=%s", name);

  ((XNav*)ip->EditorContext)->command(cmd);
  ((XNav*)ip->EditorContext)->refresh();
  return 1;
}
예제 #9
0
int	XCrr::crossref()
{
  int sts;
  pwr_tAName name;
  pwr_tClassId classid;
  char file[20] = "*";

  sts = gdh_AttrrefToName ( &objar, name, sizeof(name), cdh_mNName);
  if ( EVEN(sts)) return sts;

  sts = gdh_GetAttrRefTid( &objar, &classid);
  if ( EVEN(sts)) return sts;

  switch ( classid)
  {
    case pwr_cClass_Di:
    case pwr_cClass_Dv:
    case pwr_cClass_Do:
    case pwr_cClass_Po:
    case pwr_cClass_Av:
    case pwr_cClass_Ai:
    case pwr_cClass_Ao:
    case pwr_cClass_Iv:
    case pwr_cClass_Ii:
    case pwr_cClass_Io:
    case pwr_cClass_Co:
    case pwr_cClass_Sv:
    case pwr_cClass_ATv:
    case pwr_cClass_DTv:
      sts = xnav_crr_signal( xcrrnav->brow, file, name, NULL);
      break;
    default:
      /* Not a signal */
      sts = xnav_crr_object( xcrrnav->brow, file, name, NULL);
  }
  // if ( EVEN(sts))
  //  xnav->message(' ', XNav::get_message(sts));

  return XATT__SUCCESS;
}
예제 #10
0
XttFastGtk::XttFastGtk( void *parent_ctx,
			GtkWidget *parent_wid,
			char *name,
			GtkWidget **w,
			pwr_sAttrRef *fast_arp,
			int width,
			int height,
			unsigned int options,
			int xn_color_theme, 
			void *basewidget,
			int *sts) :
  XttFast( parent_ctx, name, fast_arp, xn_color_theme, sts), parent_widget(parent_wid)
{
  char title[250];
    
  if ( EVEN(*sts))
    return;

  *sts = XNAV__SUCCESS;

  if ( strcmp( name, "") != 0)
    strncpy( title, name, sizeof(title));
  else
    gdh_AttrrefToName( fast_arp, title, sizeof(title), cdh_mNName);

  curve = new GeCurveGtk( this, parent_widget, title, NULL, gcd, 0, width, height,
			  options, color_theme, basewidget);
  curve->close_cb = fast_close_cb;
  curve->help_cb = fast_help_cb;
  curve->export_cb = fast_export_cb;
  setup();

  wow = new CoWowGtk( parent_widget);
  timerid = wow->timer_new();

  timerid->add( 1000, fast_scan, this);
}
예제 #11
0
/* aaref points to ActualValue */
static int IsDisabled( pwr_tAttrRef *aaref)
{
  pwr_tDisableAttr disabled;
  pwr_tAName name;
  pwr_tAttrRef oaref;
  pwr_tStatus sts;
  char *s;
  
  sts = gdh_AttrrefToName( aaref, name, sizeof(name), cdh_mNName);  
  if ( EVEN(sts)) return 0;

  if ( (s = strrchr( name, '.')))
    *s = 0;
  else
    return 0;
       
  sts = gdh_NameToAttrref( pwr_cNObjid, name, &oaref);
  if ( EVEN(sts)) return 0;

  sts = gdh_ArefDisabled( &oaref, &disabled);
  if ( ODD(sts) && disabled)
    return 1;
  return 0;
}
예제 #12
0
static void  attrvalue_to_string( int type_id, void *value_ptr, 
	char *str, int size, int *len, char *format)
{
  pwr_tObjid		objid;
  pwr_sAttrRef		*attrref;
  int			sts;
  char			timstr[64];

  if ( value_ptr == 0)
  {
    strcpy( str, "UNDEFINED");
    return;
  }

  switch ( type_id )
  {
    case pwr_eType_Boolean:
    {
      if ( !format)
        *len = sprintf( str, "%d", *(pwr_tBoolean *)value_ptr);
      else
        *len = sprintf( str, format, *(pwr_tBoolean *)value_ptr);
      break;
    }
    case pwr_eType_Float32:
    {
      if ( !format)
        *len = sprintf( str, "%f", *(float *)value_ptr);
      else
        *len = sprintf( str, format, *(float *)value_ptr);
      break;
    }
    case pwr_eType_Float64:
    {
      if ( !format)
        *len = sprintf( str, "%f", *(double *)value_ptr);
      else
        *len = sprintf( str, format, *(double *)value_ptr);
      break;
    }
    case pwr_eType_Char:
    {
      if ( !format)
        *len = sprintf( str, "%c", *(char *)value_ptr);
      else
        *len = sprintf( str, format, *(char *)value_ptr);
      break;
    }
    case pwr_eType_Int8:
    {
      if ( !format)
        *len = sprintf( str, "%d", *(char *)value_ptr);
      else
        *len = sprintf( str, format, *(char *)value_ptr);
      break;
    }
    case pwr_eType_Int16:
    {
      if ( !format)
        *len = sprintf( str, "%hd", *(short *)value_ptr);
      else
        *len = sprintf( str, format, *(short *)value_ptr);
      break;
    }
    case pwr_eType_Int32:
    {
      if ( !format)
        *len = sprintf( str, "%d", *(int *)value_ptr);
      else
        *len = sprintf( str, format, *(int *)value_ptr);
      break;
    }
    case pwr_eType_Int64:
    {
      if ( !format)
        *len = sprintf( str, pwr_dFormatInt64, *(pwr_tInt64 *)value_ptr);
      else
        *len = sprintf( str, format, *(pwr_tInt64 *)value_ptr);
      break;
    }
    case pwr_eType_UInt8:
    {
      if ( !format)
        *len = sprintf( str, "%d", *(unsigned char *)value_ptr);
      else
        *len = sprintf( str, format, *(unsigned char *)value_ptr);
      break;
    }
    case pwr_eType_UInt16:
    {
      if ( !format)
        *len = sprintf( str, "%hd", *(unsigned short *)value_ptr);
      else
        *len = sprintf( str, format, *(unsigned short *)value_ptr);
      break;
    }
    case pwr_eType_UInt32:
    case pwr_eType_Mask:
    case pwr_eType_Enum:
    {
      if ( !format)
        *len = sprintf( str, "%d", *(unsigned int *)value_ptr);
      else
        *len = sprintf( str, format, *(unsigned int *)value_ptr);
      break;
    }
    case pwr_eType_UInt64:
    {
      if ( !format)
        *len = sprintf( str, pwr_dFormatUInt64, *(pwr_tUInt64 *)value_ptr);
      else
        *len = sprintf( str, format, *(pwr_tUInt64 *)value_ptr);
      break;
    }
    case pwr_eType_String:
    {
      strncpy( str, (char *)value_ptr, size);
      str[size-1] = 0;
      *len = strlen(str);
      break;
    }
    case pwr_eType_Objid:
    {
      pwr_tOName hiername;

      objid = *(pwr_tObjid *)value_ptr;
      if ( !objid.oix)
        sts = gdh_ObjidToName ( objid, hiername, sizeof(hiername), 
			 cdh_mName_volumeStrict);
      else
        sts = gdh_ObjidToName ( objid, hiername, sizeof(hiername), 
		cdh_mNName);
      if (EVEN(sts))
      {
        strcpy( str, "");
        *len = 0;
        break;
      }
      *len = sprintf( str, "%s", hiername);
      break;
    }
    case pwr_eType_AttrRef:
    {
      pwr_tAName hiername;

      attrref = (pwr_sAttrRef *) value_ptr;
      sts = gdh_AttrrefToName ( attrref, hiername, sizeof(hiername), cdh_mNName);
      if (EVEN(sts))
      {
        strcpy( str, "");
        *len = 0;
        break;
      }
      *len = sprintf( str, "%s", hiername);
      break;
    }
    case pwr_eType_Time:
    {
      sts = time_AtoAscii( (pwr_tTime *) value_ptr, time_eFormat_DateAndTime, 
		timstr, sizeof(timstr));
      if ( EVEN(sts))
        strcpy( timstr, "-");
      *len = sprintf( str, "%s", timstr);
      break;
    }
    case pwr_eType_DeltaTime:
    {
      sts = time_DtoAscii( (pwr_tDeltaTime *) value_ptr, 1, 
		timstr, sizeof(timstr));
      if ( EVEN(sts))
        strcpy( timstr, "Undefined time");
      *len = sprintf( str, "%s", timstr);
      break;
    }
    case pwr_eType_ObjectIx:
    {
      *len = sprintf( str, "%s", cdh_ObjectIxToString( NULL, 
		*(pwr_tObjectIx *) value_ptr, 1));
      break;
    }
    case pwr_eType_ClassId:
    {
      pwr_tOName hiername;

      objid = cdh_ClassIdToObjid( *(pwr_tClassId *) value_ptr);
      sts = gdh_ObjidToName ( objid, hiername, sizeof(hiername), cdh_mNName);
      if (EVEN(sts))
      {
        strcpy( str, "");
        *len = 0;
        break;
      }
      *len = sprintf( str, "%s", hiername);
      break;
    }
    case pwr_eType_TypeId:
    {
      pwr_tOName hiername;

      objid = cdh_TypeIdToObjid( *(pwr_tTypeId *) value_ptr);
      sts = gdh_ObjidToName ( objid, hiername, sizeof(hiername), cdh_mNName);
      if (EVEN(sts))
      {
        strcpy( str, "");
        *len = 0;
        break;
      }
      *len = sprintf( str, "%s", hiername);
      break;
    }
    case pwr_eType_VolumeId:
    {
      *len = sprintf( str, "%s", cdh_VolumeIdToString( NULL, 
		*(pwr_tVolumeId *) value_ptr, 1, 0));
      break;
    }
    case pwr_eType_RefId:
    {
      *len = sprintf( str, "%s", cdh_SubidToString( NULL, 
		*(pwr_tSubid *) value_ptr, 1));
      break;
    }

  }
}
예제 #13
0
XAttMotif::XAttMotif( Widget 		xa_parent_wid,
                      void 		*xa_parent_ctx,
                      pwr_sAttrRef 	*xa_objar,
                      int 		xa_advanced_user,
                      int             *xa_sts) :
    XAtt( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
    parent_wid(xa_parent_wid), set_focus_disabled(0),
    value_current_recall(0)
{
    char		uid_filename[120] = {"xtt_xatt.uid"};
    char		*uid_filename_p = uid_filename;
    Arg 		args[20];
    pwr_tStatus	sts;
    pwr_tAName   	title;
    int		i;
    MrmHierarchy s_DRMh;
    MrmType dclass;
    char		name[] = "Proview/R Navigator";

    static char translations[] =
        "<FocusIn>: xatt_inputfocus()\n";
    static XtTranslations compiled_translations = NULL;

    static XtActionsRec actions[] =
    {
        {(char*) "xatt_inputfocus",      (XtActionProc) action_inputfocus}
    };

    static MrmRegisterArg	reglist[] = {
        {(char*) "xatt_ctx", 0 },
        {(char*) "xatt_activate_exit",(caddr_t)activate_exit },
        {(char*) "xatt_activate_display_object",(caddr_t)activate_display_object },
        {(char*) "xatt_activate_show_cross",(caddr_t)activate_show_cross },
        {(char*) "xatt_activate_open_classgraph",(caddr_t)activate_open_classgraph },
        {(char*) "xatt_activate_open_plc",(caddr_t)activate_open_plc },
        {(char*) "xatt_activate_change_value",(caddr_t)activate_change_value },
        {(char*) "xatt_activate_close_changeval",(caddr_t)activate_close_changeval },
        {(char*) "xatt_activate_help",(caddr_t)activate_help },
        {(char*) "xatt_create_msg_label",(caddr_t)create_msg_label },
        {(char*) "xatt_create_cmd_prompt",(caddr_t)create_cmd_prompt },
        {(char*) "xatt_create_cmd_input",(caddr_t)create_cmd_input },
        {(char*) "xatt_create_cmd_scrolledinput",(caddr_t)create_cmd_scrolledinput },
        {(char*) "xatt_create_cmd_scrolled_ok",(caddr_t)create_cmd_scrolled_ok },
        {(char*) "xatt_create_cmd_scrolled_ca",(caddr_t)create_cmd_scrolled_ca },
        {(char*) "xatt_create_xattnav_form",(caddr_t)create_xattnav_form },
        {(char*) "xatt_activate_cmd_scrolledinput",(caddr_t)activate_cmd_input },
        {(char*) "xatt_activate_cmd_scrolled_ok",(caddr_t)activate_cmd_scrolled_ok },
        {(char*) "xatt_activate_cmd_scrolled_ca",(caddr_t)activate_cmd_scrolled_ca }
    };

    static int	reglist_num = (sizeof reglist / sizeof reglist[0]);

    // for ( i = 0; i < int(sizeof(value_recall)/sizeof(value_recall[0])); i++)
    //  value_recall[i][0] = 0;

    Lng::get_uid( uid_filename, uid_filename);

    // Create object context
//  attrctx->close_cb = close_cb;
//  attrctx->redraw_cb = redraw_cb;

    // Motif
    MrmInitialize();

    *xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
    if ( EVEN(*xa_sts)) return;

    cdh_StrncpyCutOff( title, title, 100, 1);

    reglist[0].value = (caddr_t) this;

    // Save the context structure in the widget
    i = 0;
    XtSetArg (args[i], XmNuserData, (XtPointer) this);
    i++;
    XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);
    i++;

    sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
    if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);

    MrmRegisterNames(reglist, reglist_num);

    parent_wid = XtCreatePopupShell( title,
                                     topLevelShellWidgetClass, parent_wid, args, i);

    sts = MrmFetchWidgetOverride( s_DRMh, (char*) "xatt_window", parent_wid,
                                  name, args, 1, &toplevel, &dclass);
    if (sts != MrmSUCCESS)  printf("can't fetch %s\n", name);

    MrmCloseHierarchy(s_DRMh);


    if (compiled_translations == NULL)
        XtAppAddActions( XtWidgetToApplicationContext(toplevel),
                         actions, XtNumber(actions));

    if (compiled_translations == NULL)
        compiled_translations = XtParseTranslationTable(translations);
    XtOverrideTranslations( toplevel, compiled_translations);

    i = 0;
    XtSetArg(args[i],XmNwidth,420);
    i++;
    XtSetArg(args[i],XmNheight,600);
    i++;
    XtSetValues( toplevel ,args,i);

    XtManageChild( toplevel);
    XtUnmanageChild( cmd_input);
    XtUnmanageChild( cmd_scrolledinput);
    XtUnmanageChild( cmd_scrolled_ok);
    XtUnmanageChild( cmd_scrolled_ca);

    xattnav = new XAttNavMotif( (void *)this, xattnav_form, xattnav_eType_Object,
                                "Plant", &objar, xa_advanced_user, &brow_widget, &sts);
    xattnav->message_cb = &message_cb;
    xattnav->change_value_cb = &change_value_cb;
    xattnav->popup_menu_cb = &xatt_popup_menu_cb;
    xattnav->is_authorized_cb = &xatt_is_authorized_cb;

    XtPopup( parent_wid, XtGrabNone);

    // Connect the window manager close-button to exit
    flow_AddCloseVMProtocolCb( parent_wid,
                               (XtCallbackProc)activate_exit, this);

    *xa_sts = XATT__SUCCESS;
}
예제 #14
0
static int graph_object_dx( Graph *graph, pwr_sAttrRef *arp)
{
    int sts;
    graph_sObjectDx *od;
    pwr_tAttrRef aref, chanaref;
    pwr_tAName aname;
    pwr_tCid card_cid;

    od = (graph_sObjectDx *) calloc( 1, sizeof(graph_sObjectDx));
    graph->graph_object_data = (void *) od;
    graph->graph_object_close = graph_object_dx_close;

    sts = gdh_GetAttrRefTid( arp, &od->cid);
    if ( EVEN(sts)) return sts;

    // Get channel object
    sts = gdh_ArefANameToAref( arp, "SigChanCon", &aref);
    if ( EVEN(sts)) {
        // Dv object, register scan function and return with success
        graph->graph_object_scan = graph_object_dx_scan;
        return 1;
    }

    sts = gdh_GetObjectInfoAttrref( &aref, &chanaref, sizeof(chanaref));
    if ( EVEN(sts)) return sts;

    od->local_conv_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "ConversionOn",
                       pwr_eType_Boolean);
    od->local_inv_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "InvertOn",
                      pwr_eType_Boolean);
    od->local_test_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "TestOn",
                       pwr_eType_Boolean);

    // Get card object
    if ( chanaref.Flags.b.ObjectAttr) {
        sts = gdh_GetObjectClass( chanaref.Objid, &card_cid);
        if ( EVEN(sts)) return sts;
    }
    else
        card_cid = 0;

    switch ( card_cid) {
    case pwr_cClass_Ssab_DI32D: {
        pwr_tAName card_name;
        unsigned int chan_idx = (chanaref.Offset - pwr_AlignLW(sizeof(pwr_sClass_Ssab_BaseDiCard))) / pwr_AlignLW(sizeof(pwr_sClass_ChanDi));

        sts = gdh_ObjidToName( chanaref.Objid, card_name, sizeof(card_name), cdh_mNName);
        if ( EVEN(sts)) return sts;

        if ( chan_idx < 16) {
            strcpy( aname, card_name);
            strcat( aname, ".ConvMask1");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            strcpy( aname, card_name);
            strcat( aname, ".InvMask1");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            od->mask = 1 << chan_idx;
        }
        else if ( chan_idx < 32) {
            strcpy( aname, card_name);
            strcat( aname, ".ConvMask2");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            strcpy( aname, card_name);
            strcat( aname, ".InvMask2");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            od->mask = 1 << (chan_idx - 16);
        }
        else
            return 0;

        break;
    }
    case pwr_cClass_Ssab_DO32DKS:
    case pwr_cClass_Ssab_DO32DKS_Stall: {
        pwr_tAName card_name;
        unsigned int chan_idx = (chanaref.Offset - pwr_AlignLW(sizeof(pwr_sClass_Ssab_BaseDoCard))) / pwr_AlignLW(sizeof(pwr_sClass_ChanDo));

        sts = gdh_ObjidToName( chanaref.Objid, card_name, sizeof(card_name), cdh_mNName);
        if ( EVEN(sts)) return sts;

        if ( chan_idx < 16) {
            strcpy( aname, card_name);
            strcat( aname, ".TestMask1");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            strcpy( aname, card_name);
            strcat( aname, ".InvMask1");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            od->mask = 1 << chan_idx;
        }
        else if ( chan_idx < 32) {
            strcpy( aname, card_name);
            strcat( aname, ".TestMask2");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            strcpy( aname, card_name);
            strcat( aname, ".InvMask2");

            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
                                    sizeof(pwr_tBoolean), 0, true);

            od->mask = 1 << (chan_idx - 16);
        }
        else
            return 0;

        if ( od->local_conv_p)
            *od->local_conv_p = 1;

        break;
    }
    default: {
        pwr_tAName chan_name;

        sts = gdh_AttrrefToName( &chanaref, chan_name, sizeof(chan_name),
                                 cdh_mNName);
        if ( ODD(sts)) {
            if ( od->cid == pwr_cClass_Di) {
                strcpy( aname, chan_name);
                strcat( aname, ".ConversionOn");
                graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid,
                                        sizeof(pwr_tBoolean), 0, true);
            }


            strcpy( aname, chan_name);
            strcat( aname, ".InvertOn");
            graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
                                    sizeof(pwr_tBoolean), 0, true);


            if ( od->cid == pwr_cClass_Do) {
                strcpy( aname, chan_name);
                strcat( aname, ".TestOn");
                graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_subid,
                                        sizeof(pwr_tBoolean), 0, true);

                if ( od->local_conv_p)
                    *od->local_conv_p = 1;
            }
        }
    }
    }

    // Register scan function
    graph->graph_object_scan = graph_object_dx_scan;
    return 1;
}
예제 #15
0
XCrrGtk::XCrrGtk( 
	GtkWidget      	*xa_parent_wid,
	void 		*xa_parent_ctx, 
	pwr_sAttrRef 	*xa_objar,
	int 		xa_advanced_user,
        int             *xa_sts) :
  XCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
  parent_wid(xa_parent_wid)
{
  int sts;
  pwr_tAName   	title;

  *xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
  if ( EVEN(*xa_sts)) return;

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
					 "default-height", 420,
					 "default-width", 600,
					 "title", CoWowGtk::convert_utf8(title),
					 NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect( functions_open_plc, "activate", 
		    G_CALLBACK(activate_openplc), this);
  gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
  			      'l', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);


  GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // Help entry
  GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  xcrrnav = new XAttNavGtk( (void *)this, vbox, xattnav_eType_CrossRef,
			    "Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
  xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
  xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
  xcrrnav->close_cb = &xcrr_close_cb;
  xcrrnav->init_cb = &init_cb;

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  
  gtk_container_add( GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all( toplevel);

  *xa_sts = XATT__SUCCESS;
}
예제 #16
0
static int graph_object_collect_build( Graph *graph, pwr_sAttrRef *attrref)
{
    pwr_sAttrRef *alist, *ap;
    int *is_attrp, *is_attr;
    int sts;
    char name[120];
    double x1, y1;
    grow_sAttrInfo *grow_info, *grow_info_p;
    int grow_info_cnt;
    int i;
    grow_tObject scantime_button;
    grow_tObject hold_button;
    grow_tObject t1, l1;
    double z_width, z_height, z_descent;
    double name_width = 0;
    double trend_width = 48;
    double trend_height = 1.2;
    double y0 = 2.2;
    double x0 = 2;
    pwr_tTypeId attr_type;
    unsigned int attr_size, attr_offset, attr_dimension;
    GeDyn *dyn;
    char attr_name[120];
    grow_sAttributes grow_attr;
    unsigned long mask;
    int trend_cnt = 0;


    if ( ! graph->get_current_objects_cb)
        return 0;

    sts = (graph->get_current_objects_cb) (graph->parent_ctx, &alist, &is_attr);
    if ( EVEN(sts)) return sts;

    if ( cdh_ObjidIsNull( alist->Objid))
        return 0;

    graph->graph_object_data = 0;
    graph->graph_object_close = 0;

    grow_SetPath( graph->grow->ctx, 1, "pwr_exe:");

    // Set graph attributes

    // Default color theme
    mask = grow_eAttr_color_theme;
    strcpy( grow_attr.color_theme, "$default");
    grow_SetAttributes( graph->grow->ctx, &grow_attr, mask);
    grow_ReadCustomColorFile( graph->grow->ctx, 0);

    grow_SetBackgroundColor( graph->grow->ctx, glow_eDrawType_CustomColor1);

    // Scantime input field
    graph->create_node( NULL, "pwrct_valueinputsmallbg", x0, y0 - 1.3, 4, y0 - 1.3 + 1.2,
                        &scantime_button);

    dyn = new GeDyn( graph);
    grow_SetUserData( scantime_button, (void *)dyn);

    dyn->set_dyn( ge_mDynType1_Value, ge_mDynType2_No, ge_mActionType1_ValueInput, ge_mActionType2_No);
    dyn->update_elements();
    dyn->set_access( (glow_mAccess) 65535);
    dyn->set_attribute( scantime_button, "$local.ScanTime##Float32", 0);
    dyn->set_value_input( "%3.0f", 2, 10000000);

    // Hold button
    graph->create_node( "TrendHold", "pwrct_buttonsmalltoggle", x0 + trend_width/2 - 3./2,
                        y0 - 1.4 , x0 + trend_width/2 + 3./2, y0 - 1.4 + 1.2,
                        &hold_button);
    grow_SetAnnotation( hold_button, 1, "Hold", 4);

    dyn = new GeDyn( graph);
    grow_SetUserData( hold_button, (void *)dyn);

    dyn->set_access( (glow_mAccess) 65535);
    dyn->set_attribute( hold_button, "$local.TrendHold##Boolean", 0);

    //  Zero text
    grow_CreateGrowText( graph->grow->ctx, "", "0",
                         x0 + trend_width - 0.2, y0 - 0.3,
                         glow_eDrawType_TextHelvetica, glow_eDrawType_CustomColor5, 3,
                         glow_eFont_LucidaSans, glow_mDisplayLevel_1,
                         NULL, &t1);

    ap = alist;
    is_attrp = is_attr;
    x1 = x0;
    y1 = y0;
    while( cdh_ObjidIsNotNull( ap->Objid)) {
        if ( *is_attrp) {
            sts = gdh_AttrrefToName( ap, name, sizeof(name), cdh_mNName);
            if ( EVEN(sts)) return sts;

            sts = gdh_GetAttributeCharacteristics( name, &attr_type, &attr_size,
                                                   &attr_offset, &attr_dimension);
            if ( EVEN(sts)) return sts;

            switch ( attr_type) {
            case pwr_eType_Boolean: {
                grow_tObject trend;

                grow_CreateGrowTrend( graph->grow->ctx, "ActualValueTrend",
                                      x1, y1, trend_width, trend_height,
                                      glow_eDrawType_Color37,
                                      0, glow_mDisplayLevel_1, 1, 1,
                                      glow_eDrawType_Color40, NULL,
                                      &trend);
                dyn = new GeDyn( graph);
                dyn->dyn_type1 = ge_mDynType1_Trend;
                dyn->update_dyntype( trend);
                dyn->update_elements();
                grow_SetUserData( trend, (void *)dyn);

                grow_GetObjectAttrInfo( trend, NULL,
                                        &grow_info, &grow_info_cnt);

                strcpy( attr_name, name);
                strcat( attr_name, "##Boolean");
                grow_GetUserData( trend, (void **)&dyn);
                strcpy( ((GeTrend *)dyn->elements)->attribute1, attr_name);
                strcpy( ((GeTrend *)dyn->elements)->timerange_attr, "$local.ScanTime##Float32");
                strcpy( ((GeTrend *)dyn->elements)->hold_attr, "$local.TrendHold##Boolean");
                grow_info_p = grow_info;
                for ( i = 0; i < grow_info_cnt; i++) {
                    if ( strcmp( grow_info_p->name, "NoOfPoints") == 0)
                        *(int *) grow_info_p->value_p = 200;
                    else if ( strcmp( grow_info_p->name, "HorizontalLines") == 0)
                        *(int *) grow_info_p->value_p = 0;
                    else if ( strcmp( grow_info_p->name, "VerticalLines") == 0)
                        *(int *) grow_info_p->value_p = 9;
                    else if ( strcmp( grow_info_p->name, "CurveColor1") == 0)
                        *(int *) grow_info_p->value_p = glow_eDrawType_CustomColor68;
                    else if ( strcmp( grow_info_p->name, "MaxValue1") == 0)
                        *(double *) grow_info_p->value_p = 1.2;
                    else if ( strcmp( grow_info_p->name, "MinValue1") == 0)
                        *(double *) grow_info_p->value_p = -0.1;

                    grow_info_p++;
                }
                grow_FreeObjectAttrInfo( grow_info);

                // This will configure the curves
                grow_SetTrendScanTime( trend, 0.5);

                grow_SetObjectOriginalFillColor( trend, glow_eDrawType_CustomColor66);
                grow_SetObjectOriginalBorderColor( trend, glow_eDrawType_CustomColor67);

                grow_GetTextExtent( graph->grow->ctx, name,
                                    strlen(name), glow_eDrawType_TextHelvetica,
                                    4, glow_eFont_LucidaSans, &z_width, &z_height, &z_descent);

                grow_CreateGrowText( graph->grow->ctx, "", name,
                                     x1 + trend_width + 1, y1 + trend_height/2 + z_height/2,
                                     glow_eDrawType_TextHelvetica, glow_eDrawType_CustomColor5, 4,
                                     glow_eFont_LucidaSans, glow_mDisplayLevel_1,
                                     NULL, &t1);
                if ( z_width > name_width)
                    name_width = z_width;

                trend_cnt++;
                y1 += trend_height;
                break;
            }
            default:
                ;
            }
            if ( trend_cnt >= MAX_TREND_OBJECTS)
                break;
        }

        ap++;
        is_attrp++;
    }
    free( alist);
    free( is_attr);

    // Draw separator lines between name texts
    y1 = y0;
    x1 = x0 + trend_width;
    grow_CreateGrowLine( graph->grow->ctx, "",
                         x0 + trend_width, y1, x0 + trend_width + name_width + 2, y1,
                         glow_eDrawType_CustomColor4, 1, 0, NULL, &l1);

    for ( i = 0; i < trend_cnt; i++) {
        y1 += trend_height;

        grow_CreateGrowLine( graph->grow->ctx, "",
                             x0 + trend_width, y1, x0 + trend_width + name_width + 2, y1,
                             glow_eDrawType_CustomColor4, 1, 0, NULL, &l1);
    }

    // Draw frame
    grow_CreateGrowRect( graph->grow->ctx, "R1", x0 - 1.5, y0 - 2.7,
                         trend_width + name_width + 5.5, 1, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R2", x0 - 1.5, y0 + trend_cnt * trend_height + 0.5,
                         trend_width + name_width + 5.5, 5, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R3", x0 + trend_width + name_width + 2, y0 - 1.7,
                         2, y0 + trend_cnt * trend_height + 0.9, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R4", x0 - 1.5, y0 - 1.7,
                         1, y0 + trend_cnt * trend_height + 0.9, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);

    grow_SetLayout( graph->grow->ctx, x0 - 1, y0 - 2.3, x0 + trend_width +
                    name_width + 3, y0 + trend_cnt * trend_height + 1.5);

    // Set graph attributes
    mask = grow_eAttr_double_buffer_on;
    grow_attr.double_buffer_on = 1;
    grow_SetAttributes( graph->grow->ctx, &grow_attr, mask);

    return 1;
}
예제 #17
0
XAttOneMotif::XAttOneMotif( Widget xa_parent_wid,
			    void *xa_parent_ctx, 
			    pwr_sAttrRef *xa_aref,
			    char *xa_title,
			    unsigned int xa_priv,
			    int *xa_sts) :
  XAttOne( xa_parent_ctx, xa_aref, xa_title, xa_priv, xa_sts), 
  parent_wid(xa_parent_wid), set_focus_disabled(0), value_current_recall(0)
{
  char		uid_filename[120] = {"xtt_xattone.uid"};
  char		*uid_filename_p = uid_filename;
  Arg 		args[20];
  pwr_tStatus	sts;
  pwr_tAName   	title;
  int		i;
  MrmHierarchy s_DRMh;
  MrmType dclass;
  char		name[] = "Proview/R Navigator";

  static char translations[] =
    "<FocusIn>: xao_inputfocus()\n";
  static XtTranslations compiled_translations = NULL;

  static XtActionsRec actions[] =
  {
    {(char*) "xao_inputfocus",      (XtActionProc) action_inputfocus}
  };

  static MrmRegisterArg	reglist[] = {
        {(char*) "xao_ctx", 0 },
	{(char*) "xao_activate_exit",(caddr_t)activate_exit },
	{(char*) "xao_activate_help",(caddr_t)activate_help },
	{(char*) "xao_create_msg_label",(caddr_t)create_msg_label },
	{(char*) "xao_create_cmd_prompt",(caddr_t)create_cmd_prompt },
	{(char*) "xao_create_cmd_input",(caddr_t)create_cmd_input },
	{(char*) "xao_create_cmd_label",(caddr_t)create_cmd_label },
	{(char*) "xao_create_cmd_scrolledinput",(caddr_t)create_cmd_scrolledinput },
	{(char*) "xao_create_cmd_scrolled_ok",(caddr_t)create_cmd_scrolled_ok },
	{(char*) "xao_create_cmd_scrolled_ap",(caddr_t)create_cmd_scrolled_ap },
	{(char*) "xao_create_cmd_scrolled_ca",(caddr_t)create_cmd_scrolled_ca },
	{(char*) "xao_activate_cmd_scrolledinput",(caddr_t)activate_cmd_input },
	{(char*) "xao_activate_cmd_scrolled_ok",(caddr_t)activate_cmd_scrolled_ok },
	{(char*) "xao_activate_cmd_scrolled_ap",(caddr_t)activate_cmd_scrolled_ap },
	{(char*) "xao_activate_cmd_scrolled_ca",(caddr_t)activate_cmd_scrolled_ca }
	};

  static int	reglist_num = (sizeof reglist / sizeof reglist[0]);

  // for ( i = 0; i < int(sizeof(value_recall)/sizeof(value_recall[0])); i++)
  //  value_recall[i][0] = 0;

  Lng::get_uid( uid_filename, uid_filename);

  // Create object context
//  attrctx->close_cb = close_cb;
//  attrctx->redraw_cb = redraw_cb;

  // Motif
  MrmInitialize();

  *xa_sts = gdh_AttrrefToName( &aref, title, sizeof(title), cdh_mNName);
  if ( EVEN(*xa_sts)) return;

  reglist[0].value = (caddr_t) this;

  // Save the context structure in the widget
  i = 0;
  XtSetArg (args[i], XmNuserData, (XtPointer) this);i++;
  XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);i++;

  sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
  if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);

  MrmRegisterNames(reglist, reglist_num);

  parent_wid = XtCreatePopupShell( title, 
		topLevelShellWidgetClass, parent_wid, args, i);

  sts = MrmFetchWidgetOverride( s_DRMh, (char*) "xao_window", parent_wid,
			name, args, 1, &toplevel, &dclass);
  if (sts != MrmSUCCESS)  printf("can't fetch %s\n", name);

  MrmCloseHierarchy(s_DRMh);


  if (compiled_translations == NULL) 
    XtAppAddActions( XtWidgetToApplicationContext(toplevel), 
						actions, XtNumber(actions));
 
  if (compiled_translations == NULL) 
    compiled_translations = XtParseTranslationTable(translations);
  XtOverrideTranslations( toplevel, compiled_translations);

  i = 0;
  XtSetArg(args[i],XmNwidth,420);i++;
  XtSetArg(args[i],XmNheight,120);i++;
  XtSetValues( toplevel ,args,i);
    
  if ( priv & pwr_mPrv_RtWrite || priv & pwr_mPrv_System)
    access_rw = 1;
  else
    access_rw = 0;

  XtManageChild( toplevel);
  if ( access_rw) 
    XtUnmanageChild( cmd_label);
  else {
    XtUnmanageChild( cmd_input);
    XtUnmanageChild( cmd_scrolled_ok);
    XtUnmanageChild( cmd_scrolled_ap);
  }
  XtUnmanageChild( cmd_scrolledinput);


  XtPopup( parent_wid, XtGrabNone);

  // Connect the window manager close-button to exit
  flow_AddCloseVMProtocolCb( parent_wid,
	(XtCallbackProc)activate_exit, this);

  change_value( 1);

  *xa_sts = XATT__SUCCESS;
}
예제 #18
0
XttFast::XttFast( void *parent_ctx,
		  char *name,
		  pwr_sAttrRef *fast_arp,
		  int *sts) :
  xnav(parent_ctx), fast_cnt(0), timerid(0), close_cb(0), help_cb(0), first_scan(1),
  axis_configured(false)
{
  pwr_sAttrRef aref = pwr_cNAttrRef;
  pwr_tAName fast_name;
  pwr_tAName attr_name;
  pwr_sClass_DsFastCurve fp;
  int i, j;
    
  *sts = XNAV__SUCCESS;

  // Get current status of the fast objects
  i = 0;
  aref = *fast_arp;
  if ( cdh_ObjidIsNull( aref.Objid)) {
    *sts = XNAV__FASTCONFIG;
    return;
  }

  *sts = gdh_AttrrefToName( &aref, fast_name, sizeof(fast_name), 
			  cdh_mNName);
  if (EVEN(*sts)) return;

  *sts = gdh_GetObjectInfo( fast_name, &fp, sizeof(fp));
  if ( EVEN(*sts)) return;

  max_points = fp.NoOfPoints;
  fast_function = fp.Function;

  strcpy( attr_name, fast_name);
  strcat( attr_name, ".TriggTime");
  gdh_NameToAttrref( pwr_cNObjid, attr_name, &trigg_time_attr);

  if ( fast_function & fast_mFunction_BeforeTrigg) {
    strcpy( attr_name, fast_name);
    strcat( attr_name, ".TriggIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &trigg_index_attr);

    strcpy( attr_name, fast_name);
    strcat( attr_name, ".FirstIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &first_index_attr);

    strcpy( attr_name, fast_name);
    strcat( attr_name, ".LastIndex");
    gdh_NameToAttrref( pwr_cNObjid, attr_name, &last_index_attr);
  }

  // Create data for time axis
  gcd = new GeCurveData( curve_eDataType_DsTrend);
  gcd->x_data[0] = (double *) malloc( 8 * max_points);
  strcpy( gcd->x_name, "Time");
  gcd->x_axis_type[0] = curve_eAxis_x;
  memcpy( &time_buff, &fp.TimeBuffer, sizeof(time_buff));

  fast_cnt = 0;
  for ( i = 0; i < FAST_CURVES; i++) {
    if ( fp.CurveValid[i]) {
      gcd->y_data[fast_cnt] = (double *) calloc( 1, 8 * max_points);
      gcd->y_axis_type[fast_cnt] = curve_eAxis_y;
      memcpy( &buff[fast_cnt], &fp.Buffers[i], sizeof(buff[0]));
      type[fast_cnt] = (pwr_eType) fp.AttributeType[i];
      fast_idx[i] = fast_cnt;
      curve_idx[fast_cnt] = i;

      *sts = gdh_AttrrefToName( &fp.Attribute[i], attr_name, 
			    sizeof(attr_name), cdh_mNName);
      if (EVEN(*sts)) continue;
      strcpy( gcd->y_name[fast_cnt], attr_name);
      fast_cnt++;
    }
  }

  if ( !fast_cnt) {
    *sts = XNAV__NOVALIDCURVE;
    free(gcd);
    gcd = 0;
    return;
  }

  // Subscribe to object
  strcpy( attr_name, fast_name);
  strcat( attr_name, ".New");
  *sts = gdh_RefObjectInfo( attr_name, (pwr_tAddress *)&new_p, 
			    &new_subid, sizeof(pwr_tBoolean));
  if ( EVEN(*sts)) return;

  for ( i = 0; i < fast_cnt; i++) {
    switch( type[i]) {
      case pwr_eType_Float32:
      case pwr_eType_Int32:
      case pwr_eType_UInt32:
        element_size[i] = 4;
        break;
      case pwr_eType_Float64:
      case pwr_eType_Int64:
      case pwr_eType_UInt64:
        element_size[i] = 8;
        break;
      case pwr_eType_Int16:
      case pwr_eType_UInt16:
        element_size[i] = 2;
        break;
      case pwr_eType_Int8:
      case pwr_eType_UInt8:
        element_size[i] = 1;
        break;
      default:
        element_size[i] = 4;
    }
    gcd->rows[i] = max_points;
  }
  gcd->cols = fast_cnt;

  axis_configured = true;
  for ( i = 0; i < FAST_CURVES; i++) {
    if ( fp.CurveValid[i]) {
      j = fast_idx[i];
      if ( fp.YMinValue[i] != fp.YMaxValue[i])
	gcd->scale( gcd->y_axis_type[j], gcd->y_value_type[j],
		    fp.YMinValue[i],  fp.YMaxValue[i],
		    &gcd->y_min_value_axis[j], &gcd->y_max_value_axis[j],
		    &gcd->y_trend_lines[j], &gcd->y_axis_lines[j], &gcd->y_axis_linelongq[j], 
		    &gcd->y_axis_valueq[j], gcd->y_format[j], &gcd->y_axis_width[j], 1, 1);
      else
	axis_configured = false;
    }
  }


  if ( fp.Active)
    first_scan = 0;
  fast_scan( this);
  gcd->select_color( 0);

  if ( strcmp( fp.Title, "") != 0)
    strcpy( title, fp.Title);
  else
    cdh_StrncpyCutOff( title, name, sizeof(title), 1);

  // timerid = XtAppAddTimeOut(
  //	XtWidgetToApplicationContext(parent_widget), 1000,
  //	(XtTimerCallbackProc)fast_scan, this);
}
예제 #19
0
void XttMethodToolbarGtk::set_current_sensitive()
{
  if (m_disabled)
    return;

  int is_attr;
  pwr_sAttrRef aref;
  xmenu_eItemType menu_type;
  pwr_tStatus sts = 0;

  if (get_select_cb)
    sts = (get_select_cb)(m_parent_ctx, &aref, &is_attr);
  if (EVEN(sts)) {
    // Nothing selected
    for (int i = 0; i < GeMethods::opmeth_size; i++) {
      if (m_op_method_mask & (1 << i)
          && !streq(GeMethods::op_image[i], ""))
        gtk_widget_set_sensitive(m_op_button_w[i], FALSE);
    }
    for (int i = 0; i < GeMethods::mntmeth_size; i++) {
      if (m_mnt_method_mask & (1 << i)
          && !streq(GeMethods::mnt_image[i], ""))
        gtk_widget_set_sensitive(m_mnt_button_w[i], FALSE);
    }
  } else {
    gdh_sVolumeInfo info;

    // Skip extern volumes
    sts = gdh_GetVolumeInfo(aref.Objid.vid, &info);
    if (EVEN(sts))
      return;

    if (info.cid == pwr_eClass_ExternVolume) {
      for (int i = 0; i < GeMethods::opmeth_size; i++) {
        if (m_op_method_mask & (1 << i)
            && !streq(GeMethods::op_image[i], ""))
          gtk_widget_set_sensitive(m_op_button_w[i], FALSE);
      }
      for (int i = 0; i < GeMethods::mntmeth_size; i++) {
        if (m_mnt_method_mask & (1 << i)
            && !streq(GeMethods::mnt_image[i], ""))
          gtk_widget_set_sensitive(m_mnt_button_w[i], FALSE);
      }
      return;
    }

    if (aref.Flags.b.Object)
      menu_type = xmenu_eItemType_Object;
    else if (aref.Flags.b.ObjectAttr)
      menu_type = xmenu_eItemType_AttrObject;
    else
      menu_type = xmenu_eItemType_Attribute;

    pwr_tAName aname;
    pwr_sClass_XttMethodsMask xm_mask;
    int mask_store = 0;

    sts = gdh_AttrrefToName(
        &aref, aname, sizeof(aname), cdh_mName_volumeStrict);
    if (EVEN(sts))
      return;

    sts = GeMethods::get_xm_mask(
        0, aname, &xm_mask, &mask_store, methods_command_cb, m_xnav);

    for (int i = 0; i < GeMethods::opmeth_size; i++) {
      if (m_op_method_mask & (1 << i)
          && !streq(GeMethods::op_image[i], "")) {
        if (xm_mask.OpMethods & (1 << i))
          gtk_widget_set_sensitive(m_op_button_w[i], TRUE);
        else
          gtk_widget_set_sensitive(m_op_button_w[i], FALSE);
      }
    }
    for (int i = 0; i < GeMethods::mntmeth_size; i++) {
      if (m_mnt_method_mask & (1 << i)
          && !streq(GeMethods::mnt_image[i], "")) {
        if (xm_mask.MntMethods & (1 << i))
          gtk_widget_set_sensitive(m_mnt_button_w[i], TRUE);
        else
          gtk_widget_set_sensitive(m_mnt_button_w[i], FALSE);
      }
    }
    if (mask_store) {
      strcat(aname, ".XttMethodsMask");
      sts = gdh_SetObjectInfo(aname, &xm_mask, sizeof(xm_mask));
      if (EVEN(sts))
        printf("Set mask error %s\n", aname);
    }
  }
}
예제 #20
0
XAttGtk::XAttGtk(GtkWidget* xa_parent_wid, void* xa_parent_ctx,
    pwr_sAttrRef* xa_objar, int xa_advanced_user, int* xa_sts)
    : XAtt(xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
      parent_wid(xa_parent_wid)
{
  int sts;
  pwr_tAName title;

  *xa_sts = gdh_AttrrefToName(&objar, title, sizeof(title), cdh_mNName);
  if (EVEN(*xa_sts))
    return;

  str_StrncpyCutOff(title, title, 100, 1);

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 600,
      "default-width", 420, "title", CoWowGtk::convert_utf8(title), NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon(toplevel);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_print = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Print"));
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget* file_close = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(file_close),
      gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
  gtk_widget_add_accelerator(file_close, "activate", accel_g, 'w',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget* func_changevalue = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Change _Value"));
  g_signal_connect(
      func_changevalue, "activate", G_CALLBACK(activate_change_value), this);
  gtk_widget_add_accelerator(func_changevalue, "activate", accel_g, 'q',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* func_close_changeval = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("C_lose Change Value"));
  g_signal_connect(func_close_changeval, "activate",
      G_CALLBACK(activate_close_changeval), this);
  gtk_widget_add_accelerator(func_close_changeval, "activate", accel_g, 't',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* functions_open_plc = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect(
      functions_open_plc, "activate", G_CALLBACK(activate_open_plc), this);
  gtk_widget_add_accelerator(functions_open_plc, "activate", accel_g, 'l',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_display_object = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect(functions_display_object, "activate",
      G_CALLBACK(activate_display_object), this);
  gtk_widget_add_accelerator(functions_display_object, "activate", accel_g, 'd',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_show_cross = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Show C_rossreferences"));
  g_signal_connect(
      functions_show_cross, "activate", G_CALLBACK(activate_show_cross), this);
  gtk_widget_add_accelerator(functions_show_cross, "activate", accel_g, 'r',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_open_classgraph = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Open _ClassGraph"));
  g_signal_connect(functions_open_classgraph, "activate",
      G_CALLBACK(activate_open_classgraph), this);
  gtk_widget_add_accelerator(functions_open_classgraph, "activate", accel_g,
      'g', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* func_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_changevalue);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_close_changeval);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_show_cross);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_classgraph);

  GtkWidget* functions
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // Help entry
  GtkWidget* help_help = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Help"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(help_help),
      gtk_image_new_from_stock("gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator(
      help_help, "activate", accel_g, 'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget* help
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  pane = gtk_vpaned_new();

  xattnav = new XAttNavGtk((void*)this, pane, xattnav_eType_Object, "Plant",
      &objar, xa_advanced_user, 0, &brow_widget, &sts);
  xattnav->message_cb = &message_cb;
  xattnav->change_value_cb = &change_value_cb;
  xattnav->popup_menu_cb = &xatt_popup_menu_cb;
  xattnav->is_authorized_cb = &xatt_is_authorized_cb;
  xattnav->init_cb = &init_cb;

  GtkWidget* statusbar = gtk_hbox_new(FALSE, 0);
  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);
  cmd_prompt = gtk_label_new("value > ");
  gtk_widget_set_size_request(cmd_prompt, -1, 25);
  cmd_entry = new CoWowEntryGtk(&value_recall);
  cmd_input = cmd_entry->widget();
  gtk_widget_set_size_request(cmd_input, -1, 25);
  g_signal_connect(cmd_input, "activate", G_CALLBACK(activate_cmd_input), this);

  gtk_box_pack_start(GTK_BOX(statusbar), msg_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 0);

  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(pane), TRUE, TRUE, 0);

  gtk_paned_pack1(GTK_PANED(pane), GTK_WIDGET(brow_widget), TRUE, TRUE);
  gtk_paned_pack2(GTK_PANED(pane), GTK_WIDGET(statusbar), FALSE, TRUE);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);

  cmd_scrolled_buffer = gtk_text_buffer_new(NULL);
  g_signal_connect_after(cmd_scrolled_buffer, "insert-text",
      G_CALLBACK(action_text_inserted), this);

  cmd_scrolledtextview = gtk_text_view_new_with_buffer(cmd_scrolled_buffer);
  GtkWidget* viewport = gtk_viewport_new(NULL, NULL);
  GtkWidget* scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), cmd_scrolledtextview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);

  cmd_scrolled_ok = gtk_button_new_with_label("Ok");
  gtk_widget_set_size_request(cmd_scrolled_ok, 70, 25);
  g_signal_connect(
      cmd_scrolled_ok, "clicked", G_CALLBACK(activate_cmd_scrolled_ok), this);
  cmd_scrolled_ca = gtk_button_new_with_label("Cancel");
  gtk_widget_set_size_request(cmd_scrolled_ca, 70, 25);
  g_signal_connect(
      cmd_scrolled_ca, "clicked", G_CALLBACK(activate_cmd_scrolled_ca), this);

  GtkWidget* hboxbuttons = gtk_hbox_new(TRUE, 40);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), cmd_scrolled_ok, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(hboxbuttons), cmd_scrolled_ca, FALSE, FALSE, 0);

  cmd_scrolledinput = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(cmd_scrolledinput), scrolledwindow, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(cmd_scrolledinput), hboxbuttons, FALSE, FALSE, 5);

  gtk_box_pack_start(GTK_BOX(statusbar), cmd_scrolledinput, TRUE, TRUE, 0);

  gtk_widget_show_all(toplevel);

  g_object_set(cmd_prompt, "visible", FALSE, NULL);
  g_object_set(cmd_input, "visible", FALSE, NULL);
  g_object_set(cmd_scrolledinput, "visible", FALSE, NULL);

  int w, h;
  gdk_drawable_get_size(pane->window, &w, &h);
  gtk_paned_set_position(GTK_PANED(pane), h - 50);

  *xa_sts = XATT__SUCCESS;
}
예제 #21
0
int GeMethods::get_xm_mask(pwr_tAttrRef* arp, char* name,
    pwr_sClass_XttMethodsMask* xm_mask, int* configured,
    int(command_cb)(char* cmd, void* udata), void* udata)
{
  pwr_tAName aname, xm_name;
  pwr_tStatus sts;
  pwr_tCmd command;
  int mask_configure = 0;

  *configured = 0;
  if (name) {
    strncpy(aname, name, sizeof(aname));
  } else {
    sts = gdh_AttrrefToName(arp, aname, sizeof(aname), cdh_mName_pathStrict);
    if (EVEN(sts))
      return sts;
  }

  strcpy(xm_name, aname);
  strcat(xm_name, ".XttMethodsMask");
  sts = gdh_GetObjectInfo(xm_name, xm_mask, sizeof(*xm_mask));
  if (ODD(sts)) {
    if (!(xm_mask->Flags & pwr_mXttMethodsFlagsMask_IsConfigured)) {
      mask_configure = 1;
      *configured = 1;
    }
  } else {
    mask_configure = 1;
    xm_mask->Flags = 0;
  }

  if (mask_configure) {
    xm_mask->OpMethods = 0;
    for (int i = 0; i < opmeth_size; i++) {
      if (streq(op_name[i], ""))
        continue;

      sprintf(
          command, "check method/filter=\"%s\"/object=%s", op_filter[i], aname);

      sts = (command_cb)(command, udata);
      if (ODD(sts))
        xm_mask->OpMethods |= 1 << i;
    }
    xm_mask->MntMethods = 0;

    for (int i = 0; i < mntmeth_size; i++) {
      if (streq(mnt_name[i], ""))
        continue;

      sprintf(command, "check method/filter=\"%s\"/object=%s", mnt_filter[i],
          aname);

      sts = (command_cb)(command, udata);
      if (ODD(sts))
        xm_mask->MntMethods |= 1 << i;
    }
    xm_mask->Flags |= pwr_mXttMethodsFlagsMask_IsConfigured;
  }
  return 1;
}
예제 #22
0
int XNav::getAllMenuItems( xmenu_sMenuCall	*ip,
			   xmenu_sMenuItem	**Item,
			   pwr_tObjid		objid,
			   pwr_tUInt32		Level,
			   int			*nItems,
			   int			AddSeparator,
			   pwr_sAttrRef		*CurrentObject)
{
  int                   sts;
  pwr_tCid	        classid;
  pwr_tObjid            child;
  pwr_sMenuButton	*mbp;
  pwr_sMenuCascade	*mcp;
  pwr_sMenuRef		*mrp;
  pwr_tStatus           (*filter)( xmenu_sMenuCall *);
  int                   sensitive;
  int                   i;


  Level++;
  memset(*Item, 0, sizeof(**Item));

  if(AddSeparator) {
    (*Item)->Level = Level;
    (*Item)->Item = xmenu_eMenuItem_Separator;
    (*Item)->MenuObject = pwr_cNObjid;
    (*Item)++;
    (*nItems)++;
  } 
  else {
    sts = gdh_GetObjectClass( objid, &classid);
    if ( EVEN(sts)) return sts;

    if ( classid == pwr_eClass_MenuButton) {
      sts = gdh_ObjidToPointer( objid, (void **) &mbp);
      if ( EVEN(sts)) return sts;

      
      ip->ChosenItem = *nItems;
      for ( i = 0; i < 5; i++) {
        strcpy( (*Item)->FilterArguments[i], mbp->FilterArguments[i]);
      }

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      sensitive = 1;
      if ( strcmp( mbp->FilterName, "") != 0) {
        sts = GetMethod( mbp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
	  if ( sts == XNAV__INSENSITIVE) 
            sensitive = 0;
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
        (*Item)->Level = Level;
        (*Item)->Item = xmenu_eMenuItem_Button;
        (*Item)->MenuObject = objid;

        (*Item)->Flags.f.Sensitive = sensitive;
        if (strcmp( mbp->MethodName, "")  == 0)
          (*Item)->Flags.f.Sensitive = 0;

        strcpy((*Item)->Name, mbp->ButtonName);
        strcpy( (*Item)->Method, mbp->MethodName);
        strcpy( (*Item)->Filter, mbp->FilterName);
        for ( i = 0; i < 5; i++) {
          strcpy( (*Item)->MethodArguments[i], mbp->MethodArguments[i]);
        }
        (*Item)++;
        (*nItems)++;
      }
    } 
    else if ( classid == pwr_eClass_MenuSeparator) {
      (*Item)->Level = Level;
      (*Item)->Item = xmenu_eMenuItem_Separator;
      (*Item)->MenuObject = objid;
      (*Item)++;
      (*nItems)++;
    } 
    else if ( classid == pwr_eClass_MenuCascade) {
      sts = gdh_ObjidToPointer( objid, (void **) &mcp);
      if ( EVEN(sts)) return sts;

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      if ( strcmp( mcp->FilterName, "") != 0) {
        sts = GetMethod( mcp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
        (*Item)->Level = Level;
        (*Item)->Item = xmenu_eMenuItem_Cascade;
        (*Item)->Flags.f.Sensitive = 1;
        strcpy((*Item)->Name, mcp->ButtonName);
        (*Item)->MenuObject = objid;
        (*Item)++;
        (*nItems)++;
     
        sts = gdh_GetChild( objid, &child);
        while( ODD(sts)) {
          sts = getAllMenuItems(ip, Item, child, Level, nItems, 0, CurrentObject);
          if ( EVEN(sts)) return sts;
          sts = gdh_GetNextSibling( child, &child);
        }
      }
    }
    else if ( classid == pwr_eClass_MenuRef && 
	      cdh_ObjidIsNull( CurrentObject->Objid)) {
      pwr_tAName aname;
      pwr_sAttrRef currentar;
      pwr_tCid current_cid;
      pwr_tTid a_tid;
      pwr_tUInt32 a_size, a_offs, a_elem;

      sts = gdh_ObjidToPointer( objid, (void **) &mrp);
      if ( EVEN(sts)) return sts;

      // Call any filter method
      (*Item)->CurrentObject = *CurrentObject;
      if ( strcmp( mrp->FilterName, "") != 0) {
        sts = GetMethod( mrp->FilterName, &filter);
        if ( ODD(sts)) {
          sts = (filter) ( ip);
        }
      }
      else
        sts = XNAV__SUCCESS;

      if ( ODD(sts)) {
	int create_object_button = 0;

	if ( strcmp( mrp->RefAttribute, "_SelfObject") == 0) {
	  // Object entry for attributes
	  char *s;

	  sts = gdh_AttrrefToName( &ip->Pointed, aname, sizeof(aname), cdh_mName_volumeStrict);
	  if ( EVEN(sts)) return sts;
	  if ( (s = strrchr( aname, '.')))
	    *s = 0;

	  sts = gdh_NameToAttrref( pwr_cNOid, aname, &currentar);
	  if ( EVEN(sts)) return sts;
	}
	else {
	  sts = gdh_AttrrefToName( &ip->Pointed, aname, sizeof(aname), cdh_mName_volumeStrict);
	  if ( EVEN(sts)) return sts;
	  strcat( aname, ".");
	  strcat( aname, mrp->RefAttribute);
	  
	  sts = gdh_GetAttributeCharacteristics( aname, &a_tid, &a_size,
						 &a_offs, &a_elem);
	  if ( ODD(sts)) {
	    switch ( a_tid) {
	    case pwr_eType_AttrRef:
	      sts = gdh_GetObjectInfo( aname, &currentar, sizeof(currentar));
	      break;
	    case pwr_eType_Objid: {
	      pwr_tOid oid;
	      
	      currentar = pwr_cNAttrRef;
	      sts = gdh_GetObjectInfo( aname, &oid, sizeof(oid));
	      currentar = cdh_ObjidToAref( oid);
	      break;
	    }
	    default:
	      sts = 0;
	  }
	  }
	  create_object_button = 0;
	}
	if ( ODD(sts) && cdh_ObjidIsNotNull( currentar.Objid)) {
	  (*Item)->Level = Level;
	  (*Item)->Item = xmenu_eMenuItem_Ref;
	  (*Item)->Flags.f.Sensitive = 1;
	  strcpy((*Item)->Name, mrp->ButtonName);
	  (*Item)->MenuObject = objid;
	  (*Item)++;
	  (*nItems)++;

	  // Create a label with current object name
	  sts = gdh_AttrrefToName( &currentar, aname, sizeof(aname), 
				   cdh_mNName);
	  if ( ODD(sts) && create_object_button) {
	    (*Item)->Level = Level;
	    (*Item)->Item = xmenu_eMenuItem_Button;
	    (*Item)->MenuObject = pwr_cNObjid;
	    strncpy((*Item)->Name, aname, sizeof((*Item)->Name));
	    (*Item)->Name[sizeof((*Item)->Name)-1] = 0;
	    (*Item)->MenuObject = pwr_cNObjid;
	    (*Item)->CurrentObject = currentar;
	    (*Item)->Flags.f.Sensitive = 1;
	    strcpy( (*Item)->Method, "$Object-OpenObject");
	    (*Item)++;
	    (*nItems)++;
	  }

	  sts = gdh_GetAttrRefTid( &currentar, &current_cid);
	  if ( EVEN(sts)) return sts;

	  xmenu_eItemType item_type = ip->ItemType;
	  if ( currentar.Flags.b.Object)
	    ip->ItemType =  xmenu_eItemType_Object;
	  else
	    ip->ItemType =  xmenu_eItemType_AttrObject;

	  sts = GetObjectMenu(ip, current_cid, Item, Level, nItems, 0, &currentar);
	  if ( EVEN(sts)) return sts;

	  ip->ItemType = item_type;
        }
      }
    }
  }
  return XNAV__SUCCESS;
}
예제 #23
0
static pwr_tStatus InitTrendList( trend_tCtx ctx)
{
  pwr_tStatus	    sts;
  pwr_tUInt32	    dummy;
  pwr_tTypeId	    type;
  int		    tix;
  pwr_tAttrRef	    aref;
  pwr_tAttrRef	    oaref;
  pwr_tAName   	    name;
  pwr_tDisableAttr  disabled;

  /* Init DsTrend objects */
  /* Scan through typelist and insert valid objects in list and initiate */
  /* the DsTrend objects. */

  for ( sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrend, &aref); 
	ODD(sts); 
	sts = gdh_GetNextAttrRef( pwr_cClass_DsTrend, &aref, &aref) ) {
    trend_sListEntry    *ep;
    pwr_sClass_DsTrend  *o;

    sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName);  
    if (EVEN(sts))
      continue;

    /* Check if parent object is disabled */
    sts = gdh_AttrArefToObjectAref( &aref, &oaref);
    if ( ODD(sts)) {
      sts = gdh_ArefDisabled( &oaref, &disabled);
      if ( ODD(sts) && disabled)
	continue;
    }

    ep = calloc(1, sizeof(*ep));
    if (ep == NULL) {
      errh_CErrLog(DS__ERRALLOC, NULL);
      errh_SetStatus( PWR__SRVTERM);
      exit(DS__ERRALLOC);
    }

    sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, 
		      &ep->o_subid, sizeof(*ep->o));
    if (EVEN(sts)) {
      errh_Error("Couldn't get subscription for '%s'\n%m", name, sts);
      free(ep);
      continue;
    }
    o = ep->o;       

   /* Set init values */
    o->BufferStatus[0] = 1;
    o->BufferStatus[1] = 1;
    o->NoOfBuffers = 2;
    o->NoOfBufElement = 239;

    /* Initiate DsTrend object, sampled attribute must be on local node */	  

    sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->DataName, 
		  (pwr_tAddress *)&o->DataPointer, &o->DataSubId);
    if (EVEN(sts)) {
      if ( sts == GDH__RTDBNULL && IsDisabled( &o->DataName))
	  continue;

      errh_Error("Couldn't get direct link to %s's attribute DataName\n%m", name, sts);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->DataName,
					&type, &dummy, &dummy, &dummy);
    if (EVEN(sts)) {
      errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }
    tix = cdh_TypeIdToIndex(type);

    if (!IsValidType(tix)) {
      errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }
      
    o->DataType = tix;
    if ( o->Multiple == 0)
      o->Multiple = 1;
    o->NoOfSample = (o->StorageTime * ctx->scantime) / o->Multiple;

    if(o->NoOfSample > o->NoOfBufElement)
      o->NoOfSample = o->NoOfBufElement;

    o->ScanTime = ctx->scantime;

    ep->next = ctx->o_list;
    ctx->o_list = ep;
  }

  /* Init DsTrendCurve objects */

  /* Scan through typelist and insert valid objects in list and initiate
     the DsTrend objects.  */

  for (sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrendCurve, &aref); 
       ODD(sts); 
       sts = gdh_GetNextAttrRef( pwr_cClass_DsTrendCurve, &aref, &aref) ) {
    trend_sListEntryTC  *ep;
    pwr_sClass_DsTrendCurve  *o;
    int i;
    int found;

    sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName);  
    if (EVEN(sts))
      continue;

    /* Check if parent object is disabled */
    sts = gdh_AttrArefToObjectAref( &aref, &oaref);
    if ( ODD(sts)) {
      sts = gdh_ArefDisabled( &oaref, &disabled);
      if ( ODD(sts) && disabled)
	continue;
    }

    ep = calloc(1, sizeof(*ep));
    if (ep == NULL) {
      errh_CErrLog(DS__ERRALLOC, NULL);
      errh_SetStatus( PWR__SRVTERM);
      exit(DS__ERRALLOC);
    }

    ep->first_scan = 1;

    sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, 
		      &ep->o_subid, sizeof(*ep->o));
    if (EVEN(sts)) {
      errh_Error("Couldn't get subscription for '%s'\n%m", name, sts);
      free(ep);
      continue;
    }
    o = ep->o;       

    if ( o->Function & 1) {
      /* Data stored by user */
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    ep->multiple = (int) (o->ScanTime / ctx->scantime_tc + 0.5);
    o->NoOfSample = (int) (o->StorageTime / ctx->scantime_tc * ep->multiple + 0.5);

    /* Initiate DsTrendCuve object, sampled attribute must be on local node */	  

    found = 0;
    for ( i = 0; i < 10; i++) {
      if ( cdh_ObjidIsNull( o->Attribute[i].Objid))
	continue;

      /* Link to attribute */
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Attribute[i], 
				       (pwr_tAddress *)&ep->datap[i], &ep->data_subid[i]);
      if (EVEN(sts)) {
	if ( sts == GDH__RTDBNULL && IsDisabled( &o->Attribute[i]))
	  continue;
	
	errh_Error("Couldn't get direct link to %s's attribute %d, %m", name, i+1, sts);
	ep->datap[i] = 0;
	continue;
      }
     
      sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->Attribute[i],
					&type, &dummy, &dummy, &dummy);
      if (EVEN(sts)) {
	errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      tix = cdh_TypeIdToIndex(type);
      ep->data_size[i] = cdh_TypeToSize( type);

      if (!IsValidType(tix)) {
	errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      
      o->AttributeType[i] = type;

      /* Link to buffer */
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Buffers[i], 
				       (pwr_tAddress *)&ep->buffheadp[i], &ep->buff_subid[i]);
      if (EVEN(sts)) {
	errh_Error("Couldn't get direct link to %s's buffer %d, %m", name, i+1, sts);
	gdh_UnrefObjectInfo(ep->data_subid[i]);
	ep->datap[i] = 0;
	continue;
      }
      ep->buffp[i] = (char *)ep->buffheadp[i] + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));

      /* Get buffer size */
      sts = gdh_GetAttributeCharAttrref( &o->Buffers[i], 0, &ep->buff_size[i], 0, 0);
      if ( EVEN(sts)) return sts;

      ep->buff_size[i] -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));

      found = 1;
    }
    if ( !found) {
      errh_Error("No valid attributes for %s", name);
      gdh_UnrefObjectInfo(ep->o_subid);
      free(ep);
      continue;
    }

    /* Link to time buffer */
    if ( cdh_ObjidIsNotNull( o->TimeBuffer.Objid)) {
      sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->TimeBuffer, 
				       (pwr_tAddress *)&ep->timeheadp, &ep->timebuff_subid);
      if (EVEN(sts)) {
	errh_Error("Couldn't get direct link to %s's time buffer, %m", name, sts);
	ep->timeheadp = 0;
	ep->timebuffp = 0;
      }
      else
 	ep->timebuffp = (char *)ep->timeheadp + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));
	
      if ( o->TimeResolution == pwr_eTimeResolutionEnum_Nanosecond)
	ep->time_size = 8;
      else
	ep->time_size = 4;

      /* Get buffer size */
      sts = gdh_GetAttributeCharAttrref( &o->TimeBuffer, 0, &ep->timebuff_size, 0, 0);
      if ( EVEN(sts)) return sts;

      ep->timebuff_size -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader));
    }

    /* Calculate number of samples */
    for ( i = 0; i < 10; i++) {
      if ( !ep->datap[i])
	continue;

      if ( o->NoOfSample > ep->buff_size[i] / ep->data_size[i])
	o->NoOfSample = ep->buff_size[i] / ep->data_size[i];
    }
    if ( ep->timebuffp) {
      if ( o->NoOfSample > ep->timebuff_size / ep->time_size)
	o->NoOfSample = ep->timebuff_size / ep->time_size;
    }
    for ( i = 0; i < 10; i++) {
      if ( !ep->datap[i])
	continue;

      ep->buffheadp[i]->Size = o->NoOfSample;
      ep->buffheadp[i]->ElementSize = ep->data_size[i];
    }
    if ( ep->timebuffp) {
      ep->timeheadp->Size = o->NoOfSample;
      ep->timeheadp->ElementSize = ep->time_size;
    }
     
    ep->next = ctx->o_list_tc;
    ctx->o_list_tc = ep;
  }

  if ( ctx->o_list == NULL && ctx->o_list_tc == NULL)
    return DS__NOOBJECT;
  else
    return DS__SUCCESS;
}
예제 #24
0
void fastobject::open( double base_scantime)
{
  pwr_tStatus sts;
  pwr_tUInt32 size, offs, elem;
  pwr_tTypeId type_id;
  pwr_tAName name;

  // Link to object
  sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&p, &p_dlid); 
  if ( EVEN(sts)) throw co_error(sts);

  // Link to trigg object
  if ( cdh_ObjidIsNotNull( p->TriggObject.Objid)) {
    sts = gdh_DLRefObjectInfoAttrref( &p->TriggObject, (void **)&trigg, &trigg_dlid); 
    if ( EVEN(sts)) {
      if ( p->Function & fast_mFunction_ManTrigg || 
	   p->Function & fast_mFunction_LevelTrigg)
	trigg = 0;
      else
	throw co_error(sts);
    }
  }

  // Link to attributes
  for ( int i = 0; i < FAST_CURVES; i++) {
    if ( cdh_ObjidIsNotNull( p->Attribute[i].Objid)) {
      sts = gdh_DLRefObjectInfoAttrref( &p->Attribute[i], (void **)&attributes[i], &attributes_dlid[i]);
      if ( EVEN(sts)) throw co_error(sts);

      // Get attribute type
      sts = gdh_AttrrefToName( &p->Attribute[i], name, sizeof( name), cdh_mName_volumeStrict);
      if ( EVEN(sts)) throw co_error(sts);
      
      sts = gdh_GetAttributeCharacteristics( name, &p->AttributeType[i],
					     &attributes_size[i], &offs, &elem);
      if ( EVEN(sts)) throw co_error(sts);

      p->CurveValid[i] = true;
    }
  }

  // Link to time buffer
  if ( cdh_ObjidIsNotNull( p->TimeBuffer.Objid)) {
    sts = gdh_DLRefObjectInfoAttrref( &p->TimeBuffer, (void **)&time_buffer, &time_buffer_dlid); 
    if ( EVEN(sts)) throw co_error(sts);

    // Get buffer size
    sts = gdh_AttrrefToName( &p->TimeBuffer, name, sizeof( name), cdh_mName_volumeStrict);
    if ( EVEN(sts)) throw co_error(sts);

    sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem);
    if ( EVEN(sts)) throw co_error(sts);

    if ( size < p->NoOfPoints * sizeof(pwr_tFloat32))
      p->NoOfPoints = size / sizeof(pwr_tFloat32);
  }

  // Link to attribute buffers
  for ( int i = 0; i < FAST_CURVES; i++) {
    if ( cdh_ObjidIsNotNull( p->Buffers[i].Objid) && p->CurveValid[i]) {
      p->CurveValid[i] = false;
      sts = gdh_DLRefObjectInfoAttrref( &p->Buffers[i], (void **)&buffers[i], &buffers_dlid[i]); 
      if ( EVEN(sts)) throw co_error(sts);

      p->CurveValid[i] = true;

      // Get buffer size
      sts = gdh_AttrrefToName( &p->Buffers[i], name, sizeof( name), cdh_mName_volumeStrict);
      if ( EVEN(sts)) throw co_error(sts);

      sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem);
      if ( EVEN(sts)) throw co_error(sts);

      if ( size < p->NoOfPoints * attributes_size[i])
	p->NoOfPoints = size / attributes_size[i];
    }
  }

  p->TriggMan = 0;
  p->Active = 0;
  p->Prepare = 0;
  p->TriggIndex = 0;
  if ( trigg)
    *trigg = 0;

  if ( p->ScanTime)
    scan_div = int( p->ScanTime / base_scantime + 0.5);
  else
    scan_div = 1;
  scan_base = base_scantime;
}
예제 #25
0
XAttOneGtk::XAttOneGtk(GtkWidget* xa_parent_wid, void* xa_parent_ctx,
    pwr_sAttrRef* xa_aref, char* xa_title, unsigned int xa_priv, int* xa_sts)
    : XAttOne(xa_parent_ctx, xa_aref, xa_title, xa_priv, xa_sts),
      parent_wid(xa_parent_wid)
{
  pwr_tAName title;

  *xa_sts = gdh_AttrrefToName(&aref, title, sizeof(title), cdh_mNName);
  if (EVEN(*xa_sts))
    return;

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 200,
      "default-width", 500, "title", CoWowGtk::convert_utf8(title), NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon(toplevel);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_close
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Help entry
  GtkWidget* help_help
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget* help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Prompt, label, input entry
  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);
  cmd_prompt = gtk_label_new("value > ");
  gtk_widget_set_size_request(cmd_prompt, -1, 25);
  cmd_label = gtk_label_new("");
  gtk_widget_set_size_request(cmd_label, -1, 25);
  gtk_misc_set_alignment(GTK_MISC(cmd_label), 0.0, 0.5);
  cmd_entry = new CoWowEntryGtk(&value_recall);
  cmd_input = cmd_entry->widget();
  gtk_widget_set_size_request(cmd_input, -1, 25);
  g_signal_connect(cmd_input, "activate", G_CALLBACK(activate_cmd_input), this);

  // Scrolled text input
  cmd_scrolled_buffer = gtk_text_buffer_new(NULL);

  cmd_scrolledtextview = gtk_text_view_new_with_buffer(cmd_scrolled_buffer);
  GtkWidget* viewport = gtk_viewport_new(NULL, NULL);
  GtkWidget* scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), cmd_scrolledtextview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);

  cmd_scrolledinput = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(cmd_scrolledinput), scrolledwindow, TRUE, TRUE, 0);

  // Buttons
  cmd_scrolled_ok = gtk_button_new_with_label(CoWowGtk::translate_utf8("Ok"));
  gtk_widget_set_size_request(cmd_scrolled_ok, 70, 25);
  g_signal_connect(
      cmd_scrolled_ok, "clicked", G_CALLBACK(activate_cmd_scrolled_ok), this);

  cmd_scrolled_ap
      = gtk_button_new_with_label(CoWowGtk::translate_utf8("Apply"));
  gtk_widget_set_size_request(cmd_scrolled_ap, 70, 25);
  g_signal_connect(
      cmd_scrolled_ap, "clicked", G_CALLBACK(activate_cmd_scrolled_ap), this);

  cmd_scrolled_ca
      = gtk_button_new_with_label(CoWowGtk::translate_utf8("Cancel"));
  gtk_widget_set_size_request(cmd_scrolled_ca, 70, 25);
  g_signal_connect(
      cmd_scrolled_ca, "clicked", G_CALLBACK(activate_cmd_scrolled_ca), this);

  GtkWidget* hboxbuttons = gtk_hbox_new(TRUE, 40);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), cmd_scrolled_ok, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), cmd_scrolled_ap, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(hboxbuttons), cmd_scrolled_ca, FALSE, FALSE, 0);

  // Horizontal box
  GtkWidget* statusbar = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(statusbar), msg_label, FALSE, FALSE, 15);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 15);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_label, TRUE, TRUE, 15);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 15);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_scrolledinput, TRUE, TRUE, 15);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(statusbar), TRUE, TRUE, 0);
  gtk_box_pack_start(
      GTK_BOX(vbox), GTK_WIDGET(gtk_hseparator_new()), FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all(toplevel);

  if (priv & pwr_mPrv_RtWrite || priv & pwr_mPrv_System)
    access_rw = 1;
  else
    access_rw = 0;

  if (access_rw)
    g_object_set(cmd_label, "visible", FALSE, NULL);
  else {
    g_object_set(cmd_input, "visible", FALSE, NULL);
    g_object_set(cmd_scrolledinput, "visible", FALSE, NULL);
    g_object_set(cmd_scrolled_ok, "visible", FALSE, NULL);
    g_object_set(cmd_scrolled_ap, "visible", FALSE, NULL);
  }

  change_value(1);

  *xa_sts = XATT__SUCCESS;
}
예제 #26
0
XCrrMotif::XCrrMotif( 
	Widget 		xa_parent_wid,
	void 		*xa_parent_ctx, 
	pwr_sAttrRef 	*xa_objar,
	int 		xa_advanced_user,
        int             *xa_sts) :
  XCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
  parent_wid(xa_parent_wid), set_focus_disabled(0)
{
  char		uid_filename[120] = {"xtt_xcrr.uid"};
  char		*uid_filename_p = uid_filename;
  Arg 		args[20];
  pwr_tStatus	sts;
  pwr_tAName   	title;
  int		i;
  MrmHierarchy s_DRMh;
  MrmType dclass;
  char		name[] = "Proview/R Navigator";

  static char translations[] =
    "<FocusIn>: xcrr_inputfocus()\n";
  static XtTranslations compiled_translations = NULL;

  static XtActionsRec actions[] =
  {
    {(char*) "xcrr_inputfocus",      (XtActionProc) action_inputfocus}
  };

  static MrmRegisterArg	reglist[] = {
        {(char*) "xcrr_ctx", 0 },
	{(char*) "xcrr_activate_exit",(caddr_t)activate_exit },
	{(char*) "xcrr_activate_openplc",(caddr_t)activate_openplc },
	{(char*) "xcrr_activate_help",(caddr_t)activate_help },
	{(char*) "xcrr_create_xcrrnav_form",(caddr_t)create_xcrrnav_form }
	};

  static int	reglist_num = (sizeof reglist / sizeof reglist[0]);

  Lng::get_uid( uid_filename, uid_filename);

  // Motif
  MrmInitialize();

  *xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
  if ( EVEN(*xa_sts)) return;

  reglist[0].value = (caddr_t) this;

  // Save the context structure in the widget
  i = 0;
  XtSetArg (args[i], XmNuserData, (XtPointer) this);i++;
  XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);i++;

  sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
  if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);

  MrmRegisterNames(reglist, reglist_num);

  parent_wid = XtCreatePopupShell( title, 
		topLevelShellWidgetClass, parent_wid, args, i);

  sts = MrmFetchWidgetOverride( s_DRMh, (char*) "xcrr_window", parent_wid,
			name, args, 1, &toplevel, &dclass);
  if (sts != MrmSUCCESS)  printf("can't fetch %s\n", name);

  MrmCloseHierarchy(s_DRMh);


  if (compiled_translations == NULL) 
    XtAppAddActions( XtWidgetToApplicationContext(toplevel), 
						actions, XtNumber(actions));
 
  if (compiled_translations == NULL) 
    compiled_translations = XtParseTranslationTable(translations);
  XtOverrideTranslations( toplevel, compiled_translations);

  i = 0;
  XtSetArg(args[i],XmNwidth,420);i++;
  XtSetArg(args[i],XmNheight,300);i++;
  XtSetValues( toplevel ,args,i);
    
  XtManageChild( toplevel);

  xcrrnav = new XAttNavMotif( (void *)this, xcrrnav_form, xattnav_eType_CrossRef,
			      "Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
  xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
  xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
  xcrrnav->close_cb = &xcrr_close_cb;

  XtPopup( parent_wid, XtGrabNone);

  // Connect the window manager close-button to exit
  flow_AddCloseVMProtocolCb( parent_wid,
	(XtCallbackProc)activate_exit, this);

  *xa_sts = XATT__SUCCESS;
}