예제 #1
0
static pwr_tStatus PostUnadopt (
  ldh_tSesContext Session,
  pwr_tObjid Card,	      /* current card object */
  pwr_tObjid Channel,
  pwr_tClassId Class	      /* class of child to adopt */
) {
  pwr_tStatus sts;
  pwr_sClass_Do_HVDO32 RCard;
  pwr_sClass_ChanDo ChanDo;
  pwr_sdClass_Do_HVDO32 DCard;
  pwr_tUInt32 MaxChan;
  pwr_tUInt32 Chan;
  pwr_tString80 NewName;
  
  if (Class != pwr_cClass_ChanDo)
    return PWRB__SUCCESS;

  sts = ldh_ReadObjectBody(Session, Card, "RtBody", &RCard, sizeof(RCard));
  if (EVEN(sts)) return PWRB__SUCCESS;

  sts = ldh_ReadObjectBody(Session, Card, "DevBody", &DCard, sizeof(DCard));
  if (EVEN(sts)) return PWRB__SUCCESS;

  MaxChan = co_min(32, RCard.MaxNoOfChannels);

  /*
    get attributes of channel

    NOTE !
    this should be done by a method of the channel object,
    but is not implemented in this version of PROVIEW/R.
  */

  switch (Class) {
  case pwr_cClass_ChanDo:
    sts = ldh_ReadObjectBody(Session, Channel, "RtBody", &ChanDo,
      sizeof(ChanDo));
    if (EVEN(sts)) return PWRB__SUCCESS;

    Chan = ChanDo.Number;
    break;
  }

  /* deallocate channel */
  if (Chan > MaxChan)
    return PWRB__SUCCESS;

  DCard.ChannelAllocation &= ~(1 << Chan);
  sts = ldh_SetObjectBody(Session, Card, "DevBody", (char *)&DCard, sizeof(DCard));
  if (EVEN(sts)) return PWRB__SUCCESS;

  sts = ldh_GetUniqueObjectName(Session, Channel, NewName);
  if (EVEN(sts)) return PWRB__SUCCESS;

  sts = ldh_SetObjectName(Session, Channel, NewName);
  if (EVEN(sts)) return PWRB__SUCCESS;

  return PWRB__SUCCESS;
}
예제 #2
0
static pwr_tStatus PostCreate(ldh_tSesContext Session, pwr_tObjid Object,
    pwr_tObjid Father, pwr_tClassId Class)
{
  pwr_tStatus sts;

  // Set name to Security
  sts = ldh_SetObjectName(Session, Object, "Security");
  if (EVEN(sts))
    return sts;

  return PWRS__SUCCESS;
}
예제 #3
0
static pwr_tStatus PostAdopt (
  ldh_tSesContext Session,
  pwr_tObjid Card,	      /* current card object */
  pwr_tObjid Channel,
  pwr_tClassId Class	      /* class of child to adopt */
) {
  pwr_tStatus sts;
  pwr_sClass_Do_HVDO32 RCard;
  pwr_sdClass_Do_HVDO32 DCard;
  pwr_sClass_ChanDo ChanDo;
  pwr_tUInt32 MaxChan;
  pwr_tUInt32 Chan;
  pwr_tString80 NewName;
  pwr_tString80 Description;
  pwr_tString80 Identity;
  pwr_tString80	DefName;
  pwr_sObject DefBody;
  pwr_tObjid DefObject;
  int i;
  
  if (Class != pwr_cClass_ChanDo)
    return PWRB__CHANCLASS;

  sts = ldh_ReadObjectBody(Session, Card, "RtBody", &RCard, sizeof(RCard));
  if (EVEN(sts)) return sts;

  sts = ldh_ReadObjectBody(Session, Card, "DevBody", &DCard, sizeof(DCard));
  if (EVEN(sts)) return sts;

  MaxChan = co_min(32, RCard.MaxNoOfChannels);
  for (i = 0, Chan = 1; i < (int)MaxChan; i++, Chan <<= 1) {
    if ((DCard.ChannelAllocation & Chan) == 0)
      break;
  }

  if (i >= (int)MaxChan)
    return PWRB__ALOCHAN;

  /* allocate new channel */
  DCard.ChannelAllocation |= Chan;
  sts = ldh_SetObjectBody(Session, Card, "DevBody", (char *)&DCard, sizeof(DCard));
  if (EVEN(sts)) return sts;

  /*
    change attributes of channel

    NOTE !
    this should be done by a method of the channel object,
    but is not implemented in this version of PROVIEW/R.
  */

  switch (Class) {
  case pwr_cClass_ChanDo:
    sts = ldh_ReadObjectBody(Session, Channel, "RtBody", &ChanDo,
      sizeof(ChanDo));
    if (EVEN(sts)) return sts;
    if (ChanDo.Description[0] != '\0') {
      sprintf(Description, ChanDo.Description, i);
      if (strlen(Description) <= sizeof(ChanDo.Description) - 1) {
	strcpy(ChanDo.Description, Description);
      }
    }
    if (ChanDo.Identity[0] != '\0') {
      sprintf(Identity, ChanDo.Identity, i);
      if (strlen(Identity) <= sizeof(ChanDo.Identity) - 1) {
	strcpy(ChanDo.Identity, Identity);
      }
    }

    ChanDo.Number = i;
    sts = ldh_SetObjectBody(Session, Channel, "RtBody", (char *)&ChanDo, sizeof(ChanDo));
    strcpy(DefName, "pwrb:Class-ChanDo-Defaults");
    break;
  }

  /* change name of channel */
  
  sts = ldh_NameToObjid(Session, &DefObject, DefName);
  if (EVEN(sts)) return PWRB__SUCCESS;
  sts = ldh_ReadObjectBody(Session, DefObject, "SysBody", &DefBody,
    sizeof(DefBody));
  if (DefBody.Name[0] != '\0') {
    sprintf(NewName, DefBody.Name, i+1);
    NewName[31] = '\0';
    sts = ldh_SetObjectName(Session, Channel, NewName);
  }

  return PWRB__SUCCESS;
}