/*****************************************************************************
 * File:  A_FBO_bridge.c
 *
 * Description:
 * Bridge implementation for the following application analysis object:
 *
 * Object:     bridge  (FBO)
 * Domain:     A
 * Subsystem:  autosampler
 * Repository: as2.ooa
 *
 * Notice:
 *   (C) Copyright 1999, 2000 ROX Software, Inc.
 *   All rights reserved.
 *
 * Model Compiler:  MC3020 V1.3.0
 *
 * Warnings:
 *   !!! THIS IS AN AUTO-GENERATED FILE. PLEASE DO NOT EDIT. !!!
 ****************************************************************************/

#include "e_mechs.h"
#include "e_events.h"
#include "A_objects.h"
#include "A_enums.h"
#include "A_CAR_object.h"
#include "A_CAR_events.h"
#include "A_ROW_object.h"
#include "A_ROW_events.h"
#include "A_SP_object.h"
#include "A_SP_events.h"
#include "A_FBO_bridge.h"

/*****************************************************************************
 * Bridge method:  INIT
 ****************************************************************************/
void
A_FBO_INIT( void )
{
  /* Dummy up instance handle for event generation.  */
  static Escher_InstanceHandle_t self = &self;
  A_CAR_s * v1;  /* car */
  A_ROW_s * v2;  /* row */
  A_SP_s * v3;  /* probe */

  /* CREATE OBJECT INSTANCE car OF CAR */
  v1 = A_CAR_Create();

  /* ASSIGN car.carousel_ID = 10 */
  v1->m_carousel_ID = 10;

  /* ASSIGN car.current_position = 10 */
  v1->m_current_position = 10;

  /* CREATE OBJECT INSTANCE row OF ROW */
  v2 = A_ROW_Create();

  /* RELATE row TO car ACROSS R1 */
  A_ROW_R1_Link( v1, v2 );

  /* ASSIGN row.radius = 10 */
  v2->m_radius = 10;

  /* ASSIGN row.current_sampling_position = 0 */
  v2->m_current_sampling_position = 0;

  /* ASSIGN row.maximum_sampling_positions = 20 */
  v2->m_maximum_sampling_positions = 20;

  /* ASSIGN row.sampling_time = 3000000 */
  v2->m_sampling_time = 3000000;

  /* ASSIGN row.needs_probe = FALSE */
  v2->m_needs_probe = false;

  /* CREATE OBJECT INSTANCE probe OF SP */
  v3 = A_SP_Create();

  /* ASSIGN probe.probe_ID = 1 */
  v3->m_probe_ID = 1;

  /* ASSIGN probe.radial_position = 20 */
  v3->m_radial_position = 20;

  /* ASSIGN probe.theta_offset = 40 */
  v3->m_theta_offset = 40;

  /* ASSIGN probe.current_position = 'up' */
  v3->m_current_position = A_position_up_e;

  /* ASSIGN probe.available = TRUE */
  v3->m_available = true;

}

/*****************************************************************************
 * Bridge method:  genC2there
 ****************************************************************************/
static void A_FBO_genC2there2( void ); /* Declare posted routine.  */
void
A_FBO_genC2there( void )
{
  InterleaveBridge( A_FBO_genC2there2 );
}

static void
A_FBO_genC2there2( void )
{
  /* Dummy up instance handle for event generation.  */
  static Escher_InstanceHandle_t self = &self;
  A_CAR_s * v4;  /* c */

  /* SELECT ANY c FROM INSTANCES OF CAR */
  v4 = (A_CAR_s *)Escher_SetGetAny( pG_A_CAR_extent );

  /* GENERATE CAR2:'there'() TO c */
  {
    A_CAR_Event2_s * event5 = (A_CAR_Event2_s *) Escher_NewOoaEvent( (void *) v4, &A_CAR_Event2_sc );
    SetEventSendingInstance( event5, self );
    Escher_SendEvent( (OoaEvent_t *)event5 );
  }

}

/*****************************************************************************
 * Bridge method:  genP3pip
 ****************************************************************************/
static void A_FBO_genP3pip2( void ); /* Declare posted routine.  */
void
A_FBO_genP3pip( void )
{
  InterleaveBridge( A_FBO_genP3pip2 );
}

static void
A_FBO_genP3pip2( void )
{
  /* Dummy up instance handle for event generation.  */
  static Escher_InstanceHandle_t self = &self;
  A_SP_s * v6;  /* p */

  /* SELECT ANY p FROM INSTANCES OF SP */
  v6 = (A_SP_s *)Escher_SetGetAny( pG_A_SP_extent );

  /* GENERATE SP3:'probe_in_position'(altitude:p.current_position) TO p */
  {
    A_SP_Event3_s * event7 = (A_SP_Event3_s *) Escher_NewOoaEvent( (void *) v6, &A_SP_Event3_sc );
    event7->m_altitude = v6->m_current_position;
    SetEventSendingInstance( event7, self );
    Escher_SendEvent( (OoaEvent_t *)event7 );
  }

}

/*****************************************************************************
 * Bridge method:  stopandgo
 ****************************************************************************/
void
A_FBO_stopandgo( 
    const int s_directive )
{
  /* Dummy up instance handle for event generation.  */
  static Escher_InstanceHandle_t self = &self;
  A_ROW_s * v8;  /* row */

  /* IF (RCVD_EVT.directive == 'go') */
  if ( (s_directive == A_order_go_e) )
  {
    /* SELECT ANY row FROM INSTANCES OF ROW */
    v8 = (A_ROW_s *)Escher_SetGetAny( pG_A_ROW_extent );

    /* GENERATE ROW1:'probe_request'() TO row */
    {
      A_ROW_Event1_s * event9 = (A_ROW_Event1_s *) Escher_NewOoaEvent( (void *) v8, &A_ROW_Event1_sc );
      SetEventSendingInstance( event9, self );
      Escher_SendEvent( (OoaEvent_t *)event9 );
    }
  }
  /* END IF */

}