/* Process model C form file: sta_dyn_processor_source.pr.c */
/* Portions of this file copyright 1986-2008 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char sta_dyn_processor_source_pr_c [] = "MIL_3_Tfile_Hdr_ 145A 30A op_runsim 7 59052F52 59052F52 1 winxpvm FEKT 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 1e80 8                                                                                                                                                                                                                                                                                                                                                                                                           ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */

#define SEND  (op_intrpt_type () == OPC_INTRPT_SELF && op_intrpt_code () == 1)

/* End of Header Block */

#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define	BINIT
#endif /* #if !defined (VOSD_NO_FIN) */



/* State variable definitions */
typedef struct
	{
	/* Internal state tracking for FSM */
	FSM_SYS_STATE
	/* State Variables */
	Objid	                  		ID                                              ;
	Objid	                  		ppid                                            ;
	double	                 		start_time                                      ;
	int	                    		Stations                                        ;
	double	                 		grant_size                                      ;
	double	                 		interarrival                                    ;
	double	                 		st1                                             ;
	double	                 		st2                                             ;
	double	                 		st3                                             ;
	double	                 		st4                                             ;
	double	                 		st5                                             ;
	double	                 		st6                                             ;
	double	                 		st7                                             ;
	double	                 		st8                                             ;
	int	                    		Port                                            ;
	double	                 		offset                                          ;
	double	                 		gt                                              ;
	char	                   		rezim                                           ;
	int	                    		pocitadlo                                       ;
	int	                    		aktivni_ONU                                     ;
	char	                   		rezim2                                          ;
	} sta_dyn_processor_source_state;

#define ID                      		op_sv_ptr->ID
#define ppid                    		op_sv_ptr->ppid
#define start_time              		op_sv_ptr->start_time
#define Stations                		op_sv_ptr->Stations
#define grant_size              		op_sv_ptr->grant_size
#define interarrival            		op_sv_ptr->interarrival
#define st1                     		op_sv_ptr->st1
#define st2                     		op_sv_ptr->st2
#define st3                     		op_sv_ptr->st3
#define st4                     		op_sv_ptr->st4
#define st5                     		op_sv_ptr->st5
#define st6                     		op_sv_ptr->st6
#define st7                     		op_sv_ptr->st7
#define st8                     		op_sv_ptr->st8
#define Port                    		op_sv_ptr->Port
#define offset                  		op_sv_ptr->offset
#define gt                      		op_sv_ptr->gt
#define rezim                   		op_sv_ptr->rezim
#define pocitadlo               		op_sv_ptr->pocitadlo
#define aktivni_ONU             		op_sv_ptr->aktivni_ONU
#define rezim2                  		op_sv_ptr->rezim2

/* These macro definitions will define a local variable called	*/
/* "op_sv_ptr" in each function containing a FIN statement.	*/
/* This variable points to the state variable data structure,	*/
/* and can be used from a C debugger to display their values.	*/
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC	sta_dyn_processor_source_state *op_sv_ptr;
#define FIN_PREAMBLE_CODE	\
		op_sv_ptr = ((sta_dyn_processor_source_state *)(OP_SIM_CONTEXT_PTR->_op_mod_state_ptr));


/* No Function Block */

#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif

/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing.		  */
#undef FIN_TRACING
#define FIN_TRACING

#undef FOUTRET_TRACING
#define FOUTRET_TRACING

#if defined (__cplusplus)
extern "C" {
#endif
	void sta_dyn_processor_source (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype _op_sta_dyn_processor_source_init (int * init_block_ptr);
	void _op_sta_dyn_processor_source_diag (OP_SIM_CONTEXT_ARG_OPT);
	void _op_sta_dyn_processor_source_terminate (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Address _op_sta_dyn_processor_source_alloc (VosT_Obtype, int);
	void _op_sta_dyn_processor_source_svar (void *, const char *, void **);


#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
sta_dyn_processor_source (OP_SIM_CONTEXT_ARG_OPT)
	{
#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (sta_dyn_processor_source ());

		{


		FSM_ENTER_NO_VARS ("sta_dyn_processor_source")

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "sta_dyn_processor_source [init enter execs]")
				FSM_PROFILE_SECTION_IN ("sta_dyn_processor_source [init enter execs]", state0_enter_exec)
				{
				ID = op_id_self();
				ppid = op_topo_parent(ID);
				
				op_ima_obj_attr_get(ppid,"Mode",&rezim);
				op_ima_obj_attr_get(ppid,"Modification",&rezim2);
				
				//op_ima_obj_attr_get(ppid,"Pocet ONT",&Stations);
				op_ima_obj_attr_get(ppid,"Period",&grant_size);
				op_ima_obj_attr_get(ppid,"Basic ONU-ID",&Port);
				op_ima_obj_attr_get(ppid,"Start time",&start_time);
				op_ima_obj_attr_get(ppid,"Offset",&offset);
				op_ima_obj_attr_get(ppid,"Guard Time",&gt);
				
				
				op_ima_obj_attr_get(ppid,"ONU 1",&st1);
				op_ima_obj_attr_get(ppid,"ONU 2",&st2);
				op_ima_obj_attr_get(ppid,"ONU 3",&st3);
				op_ima_obj_attr_get(ppid,"ONU 4",&st4);
				op_ima_obj_attr_get(ppid,"ONU 5",&st5);
				op_ima_obj_attr_get(ppid,"ONU 6",&st6);
				op_ima_obj_attr_get(ppid,"ONU 7",&st7);
				op_ima_obj_attr_get(ppid,"ONU 8",&st8);
				
				//sender_id=op_id_from_name(ppid,OPC_OBJTYPE_PROC,"queue");
				
				op_intrpt_schedule_self (op_sim_time()+start_time, 1);
				
				
				//interarrival=((st1+st2+st3+st4+st5+st6+st7+st8)*grant_size);
				
				}
				FSM_PROFILE_SECTION_OUT (state0_enter_exec)

			/** state (init) exit executives **/
			FSM_STATE_EXIT_FORCED (0, "init", "sta_dyn_processor_source [init exit execs]")


			/** state (init) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "init", "idle", "tr_5", "sta_dyn_processor_source [init -> idle : default / ]")
				/*---------------------------------------------------------*/



			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (1, "idle", state1_enter_exec, "sta_dyn_processor_source [idle enter execs]")

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (3,"sta_dyn_processor_source")


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (1, "idle", "sta_dyn_processor_source [idle exit execs]")


			/** state (idle) transition processing **/
			FSM_TRANSIT_ONLY ((SEND), 2, state2_enter_exec, ;, idle, "SEND", "", "idle", "proces", "tr_1", "sta_dyn_processor_source [idle -> proces : SEND / ]")
				/*---------------------------------------------------------*/



			/** state (proces) enter executives **/
			FSM_STATE_ENTER_FORCED (2, "proces", state2_enter_exec, "sta_dyn_processor_source [proces enter execs]")
				FSM_PROFILE_SECTION_IN ("sta_dyn_processor_source [proces enter execs]", state2_enter_exec)
				{
				//---------------------------staticky rezim-------------------
				if(rezim==0)
				{
				Packet * pk_send;
				Packet * tmp;
				int stat_active=0;
				int pom=0;
				int pom2=0;
				double cas;
				double time;
				double prideleny_grant=0;
				int grant_size_int;
				char own_name[50];
				
				
				double pole[8];
				int g=0;
				
				op_ima_obj_attr_get(ppid,"name",&own_name);
				
				op_ima_obj_attr_get(ppid,"ONU 1",&st1);
				op_ima_obj_attr_get(ppid,"ONU 2",&st2);
				op_ima_obj_attr_get(ppid,"ONU 3",&st3);
				op_ima_obj_attr_get(ppid,"ONU 4",&st4);
				op_ima_obj_attr_get(ppid,"ONU 5",&st5);
				op_ima_obj_attr_get(ppid,"ONU 6",&st6);
				op_ima_obj_attr_get(ppid,"ONU 7",&st7);
				op_ima_obj_attr_get(ppid,"ONU 8",&st8);
				
				pole[0]=st1;
				pole[1]=st2;
				pole[2]=st3;
				pole[3]=st4;
				pole[4]=st5;
				pole[5]=st6;
				pole[6]=st7;
				pole[7]=st8;
				
				
				for(g=0;g<8;g++)
					{
					stat_active+=pole[g];
					}
				
				prideleny_grant=(grant_size-stat_active*gt)/stat_active;
				//grant_size_int = prideleny_grant*1000000;
				
				pk_send = op_pk_create_fmt ("BWmap");
				op_pk_total_size_set (pk_send, 64);
				
				for(g=0;g<8;g++)
				{
				if(pole[g] == 1)
					{
					tmp = op_pk_copy (pk_send);
					op_pk_nfd_set (tmp, "Alloc-ID", Port+g);
					op_pk_nfd_set (tmp, "GrantSize", prideleny_grant);//grant_size_int
					cas=op_sim_time();
					cas+=(pom*prideleny_grant)+offset+gt*(pom)+pom2*0.000001;
					//time=(double)cas*10000000;
					op_pk_nfd_set (tmp, "StartTime", cas);//time
					pom+=1;
					op_pk_send (tmp, 0);
					}
					
				}
				
				printf("Staticky pridelene granty jednotkou %s: %.9f\n\n",own_name, prideleny_grant);
				
				op_intrpt_schedule_self (op_sim_time()+grant_size, 1);
				}
				
				//--------------------------------dynamicky rezim-----------------------
				else if(rezim==1)
				{
				Packet * pk_send;
				Packet * tmp;
				int stat_active=0;
				int pom=0;
				int pom2=0;
				double cas;
				
				double prideleny_grant=0;
				
				char own_name[50];
				
				double stat_active_time;
				double mezicas=0;
				
				double pole[8];
				int g=0;
				
				//*******kontrola
				double soucet=0;
				//********
				
				op_ima_obj_attr_get(ppid,"name",&own_name);
				
				op_ima_obj_attr_get(ppid,"ONU 1",&st1);
				op_ima_obj_attr_get(ppid,"ONU 2",&st2);
				op_ima_obj_attr_get(ppid,"ONU 3",&st3);
				op_ima_obj_attr_get(ppid,"ONU 4",&st4);
				op_ima_obj_attr_get(ppid,"ONU 5",&st5);
				op_ima_obj_attr_get(ppid,"ONU 6",&st6);
				op_ima_obj_attr_get(ppid,"ONU 7",&st7);
				op_ima_obj_attr_get(ppid,"ONU 8",&st8);
				
				pole[0]=st1;
				pole[1]=st2;
				pole[2]=st3;
				pole[3]=st4;
				pole[4]=st5;
				pole[5]=st6;
				pole[6]=st7;
				pole[7]=st8;
				
				for(g=0;g<8;g++)
				{
				if(pole[g] != 0)
					{stat_active++;}
				}
				
				prideleny_grant=(grant_size-stat_active*gt)/stat_active;
				stat_active_time=st1+st2+st3+st4+st5+st6+st7+st8;
				
				//*****************kontrola
				printf("\n\nStat_active_time pri pruchodu na zacatku %.9f\n",stat_active_time);
				
				//****************
				
				
				//******************
				if(pocitadlo!=1)
				{
				if(pole[0]!=0){
				op_ima_obj_attr_set(ppid,"ONU 1",prideleny_grant);}
				if(pole[1]!=0){
				op_ima_obj_attr_set(ppid,"ONU 2",prideleny_grant);}
				if(pole[2]!=0){
				op_ima_obj_attr_set(ppid,"ONU 3",prideleny_grant);}
				if(pole[3]!=0){
				op_ima_obj_attr_set(ppid,"ONU 4",prideleny_grant);}
				if(pole[4]!=0){
				op_ima_obj_attr_set(ppid,"ONU 5",prideleny_grant);}
				if(pole[5]!=0){
				op_ima_obj_attr_set(ppid,"ONU 6",prideleny_grant);}
				if(pole[6]!=0){
				op_ima_obj_attr_set(ppid,"ONU 7",prideleny_grant);}
				if(pole[7]!=0){
				op_ima_obj_attr_set(ppid,"ONU 8",prideleny_grant);}
				
				op_ima_obj_attr_get(ppid,"ONU 1",&st1);
				op_ima_obj_attr_get(ppid,"ONU 2",&st2);
				op_ima_obj_attr_get(ppid,"ONU 3",&st3);
				op_ima_obj_attr_get(ppid,"ONU 4",&st4);
				op_ima_obj_attr_get(ppid,"ONU 5",&st5);
				op_ima_obj_attr_get(ppid,"ONU 6",&st6);
				op_ima_obj_attr_get(ppid,"ONU 7",&st7);
				op_ima_obj_attr_get(ppid,"ONU 8",&st8);
				
				pole[0]=st1;
				pole[1]=st2;
				pole[2]=st3;
				pole[3]=st4;
				pole[4]=st5;
				pole[5]=st6;
				pole[6]=st7;
				pole[7]=st8;
				
				pocitadlo=1;
				aktivni_ONU=stat_active;  //pocet aktivnich onu ve state variable
				
				pk_send = op_pk_create_fmt ("BWmap");
				op_pk_total_size_set (pk_send, 64);
				//**************
				
				
				
				for(g=0;g<8;g++)
				{
				if(pole[g] != 0)
					{
					tmp = op_pk_copy (pk_send);
					op_pk_nfd_set (tmp, "Alloc-ID", Port+g);
					op_pk_nfd_set (tmp, "GrantSize", pole[g]);
					cas=op_sim_time();
					cas+=(pom*pole[g])+offset+gt*(pom)+pom2*0.000001;
					//time=(double)cas*10000000;
					op_pk_nfd_set (tmp, "StartTime", cas);
					pom+=1;
					op_pk_send (tmp, 0);
					}
					
				}
				
				
				
				printf("Staticky pridelene granty jednotkou %s:\n",own_name);
				
				
				for(g=0;g<8;g++)
				{
				printf("%.9f\n",pole[g]);
				soucet+=pole[g];
				}
				
				printf("\nSoucet casu pridelenych ve vzestupnem ramci: %.9f\n",soucet);
				printf("Guard intervaly celkem: %.9f\n",aktivni_ONU*gt);
				printf("Velikost vzestupneho ramce: %.9f\n",grant_size);
				
				
				printf("Konec pruchodu statickym pridelovanim\n------------------------\n");
				
				//************
				op_intrpt_schedule_self (op_sim_time()+grant_size, 1);
				}
				
				
				
				//********************
				else
				{
				if(stat_active_time<=grant_size-((aktivni_ONU)*gt-0.000001))//-0,000001 kvuli preeskokou se 7 jednotkami
				{	
				/********upravy 8.4.2017******
				*/
				double neprideleno=0;
				double podil=0;
				if(rezim2==1)
				{
				neprideleno=(grant_size-((aktivni_ONU)*gt))-stat_active_time;
				podil=neprideleno/aktivni_ONU;
				printf("pocet aktivnich %d\n",aktivni_ONU);
				printf("neprideleno %.9f\n",neprideleno);
				printf("podil %.9f\n",podil);
				printf("-----\n");
				for(g=0;g<8;g++)
				{
				printf("stary obsah pole %.9f\n",pole[g]);
				if(pole[g] != 0)
				{
				pole[g]+=podil;
				}
				}
				printf("-----\n");
				for(g=0;g<8;g++)
				{
				printf("novy obsah pole %.9f\n",pole[g]);
				}
				printf("-----\n");
				}
				
				/*
				/****konec uprav******
					*/
				/*
				//***********kontrolni vypis
					printf("vypis pole\n");
					for(g=0;g<8;g++)
				{//**
				printf("%.9f\n",pole[g]);
				}//**
					
					//************
				*/	
				//send packets
				pk_send = op_pk_create_fmt ("BWmap");
				op_pk_total_size_set (pk_send, 64);
				cas=op_sim_time()+offset;
				
				for(g=0;g<8;g++)
				{
				if(pole[g] != 0)
					{
					tmp = op_pk_copy (pk_send);
					op_pk_nfd_set (tmp, "Alloc-ID", Port+g);
					op_pk_nfd_set (tmp, "GrantSize", pole[g]);
					op_pk_nfd_set (tmp, "StartTime", cas);
					mezicas=pole[g]+gt;
					cas+=mezicas;
					mezicas=0;
					op_pk_send (tmp, 0);
					}
					
				}
				//*************
				
				
				printf("Dynamicky pridelene granty jednotkou %s:\n",own_name);
				
				for(g=0;g<8;g++)
				{
				printf("%.9f\n",pole[g]);
				soucet+=pole[g];
				}
				printf("Soucet grantu: %.9f\n",soucet);
				
				printf("------------------------\n");
				
				op_intrpt_schedule_self (op_sim_time()+grant_size, 1);
				
				
				}
				else
					{
					int j=0;
					double maximum=0;
					int index=0;
					do{
					stat_active_time=0;
					for(j=0;j<8;j++)
						{
						if(pole[j]>maximum)
							{
							maximum=pole[j];
							index=j;
							}
						}
					pole[index]=pole[index]-0.000001;
					
					maximum=0;
					index=0;
					for(j=0;j<8;j++)
						{
						stat_active_time+=pole[j];
						}
					
					}while(stat_active_time>grant_size-aktivni_ONU*gt);
					
					
				//***********kontrolni vypis
				printf("Granty prideleny dynamicky (velikost upravena)\n\n");
					
				printf("Vypis pole po uprave:\n");
					
					for(g=0;g<8;g++)
				{
				printf("%.9f\n",pole[g]);
				soucet+=pole[g];
				}
				printf("Soucet grantu: %.9f + %.9f soucet gt\n",soucet,(aktivni_ONU*gt));
				printf("-----------------\n");	
					//************
					
				pk_send = op_pk_create_fmt ("BWmap");
				op_pk_total_size_set (pk_send, 64);
				cas=op_sim_time()+offset;
				
				for(g=0;g<8;g++)
				{
				if(pole[g] != 0)
					{
					tmp = op_pk_copy (pk_send);
					op_pk_nfd_set (tmp, "Alloc-ID", Port+g);
					op_pk_nfd_set (tmp, "GrantSize", pole[g]);
					op_pk_nfd_set (tmp, "StartTime", cas);
					mezicas=pole[g]+gt;
					cas+=mezicas;
					mezicas=0;
					op_pk_send (tmp, 0);
					}
					
				}
				
				
				
				op_intrpt_schedule_self (op_sim_time()+grant_size, 1);
				
					}
				}
				
				}//*****konec rezimu
				//**************chybova hlaska modu
				else
				{
				printf("Spatne zadany rezim (mode)!\n\n");
				}
				
				
				
				
				
				
				
				}
				FSM_PROFILE_SECTION_OUT (state2_enter_exec)

			/** state (proces) exit executives **/
			FSM_STATE_EXIT_FORCED (2, "proces", "sta_dyn_processor_source [proces exit execs]")


			/** state (proces) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "proces", "idle", "tr_2", "sta_dyn_processor_source [proces -> idle : default / ]")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,"sta_dyn_processor_source")
		}
	}




void
_op_sta_dyn_processor_source_diag (OP_SIM_CONTEXT_ARG_OPT)
	{
	/* No Diagnostic Block */
	}




void
_op_sta_dyn_processor_source_terminate (OP_SIM_CONTEXT_ARG_OPT)
	{

	FIN_MT (_op_sta_dyn_processor_source_terminate ())


	/* No Termination Block */

	Vos_Poolmem_Dealloc (op_sv_ptr);

	FOUT
	}


/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in _op_sta_dyn_processor_source_svar function. */
#undef ID
#undef ppid
#undef start_time
#undef Stations
#undef grant_size
#undef interarrival
#undef st1
#undef st2
#undef st3
#undef st4
#undef st5
#undef st6
#undef st7
#undef st8
#undef Port
#undef offset
#undef gt
#undef rezim
#undef pocitadlo
#undef aktivni_ONU
#undef rezim2

#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE

#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE

VosT_Obtype
_op_sta_dyn_processor_source_init (int * init_block_ptr)
	{
	VosT_Obtype obtype = OPC_NIL;
	FIN_MT (_op_sta_dyn_processor_source_init (init_block_ptr))

	obtype = Vos_Define_Object_Prstate ("proc state vars (sta_dyn_processor_source)",
		sizeof (sta_dyn_processor_source_state));
	*init_block_ptr = 0;

	FRET (obtype)
	}

VosT_Address
_op_sta_dyn_processor_source_alloc (VosT_Obtype obtype, int init_block)
	{
#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	sta_dyn_processor_source_state * ptr;
	FIN_MT (_op_sta_dyn_processor_source_alloc (obtype))

	ptr = (sta_dyn_processor_source_state *)Vos_Alloc_Object (obtype);
	if (ptr != OPC_NIL)
		{
		ptr->_op_current_block = init_block;
#if defined (OPD_ALLOW_ODB)
		ptr->_op_current_state = "sta_dyn_processor_source [init enter execs]";
#endif
		}
	FRET ((VosT_Address)ptr)
	}



void
_op_sta_dyn_processor_source_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
	{
	sta_dyn_processor_source_state		*prs_ptr;

	FIN_MT (_op_sta_dyn_processor_source_svar (gen_ptr, var_name, var_p_ptr))

	if (var_name == OPC_NIL)
		{
		*var_p_ptr = (void *)OPC_NIL;
		FOUT
		}
	prs_ptr = (sta_dyn_processor_source_state *)gen_ptr;

	if (strcmp ("ID" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->ID);
		FOUT
		}
	if (strcmp ("ppid" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->ppid);
		FOUT
		}
	if (strcmp ("start_time" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->start_time);
		FOUT
		}
	if (strcmp ("Stations" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->Stations);
		FOUT
		}
	if (strcmp ("grant_size" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->grant_size);
		FOUT
		}
	if (strcmp ("interarrival" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->interarrival);
		FOUT
		}
	if (strcmp ("st1" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st1);
		FOUT
		}
	if (strcmp ("st2" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st2);
		FOUT
		}
	if (strcmp ("st3" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st3);
		FOUT
		}
	if (strcmp ("st4" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st4);
		FOUT
		}
	if (strcmp ("st5" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st5);
		FOUT
		}
	if (strcmp ("st6" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st6);
		FOUT
		}
	if (strcmp ("st7" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st7);
		FOUT
		}
	if (strcmp ("st8" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->st8);
		FOUT
		}
	if (strcmp ("Port" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->Port);
		FOUT
		}
	if (strcmp ("offset" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->offset);
		FOUT
		}
	if (strcmp ("gt" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->gt);
		FOUT
		}
	if (strcmp ("rezim" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->rezim);
		FOUT
		}
	if (strcmp ("pocitadlo" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->pocitadlo);
		FOUT
		}
	if (strcmp ("aktivni_ONU" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->aktivni_ONU);
		FOUT
		}
	if (strcmp ("rezim2" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->rezim2);
		FOUT
		}
	*var_p_ptr = (void *)OPC_NIL;

	FOUT
	}

