Example #1
0
                void optimize(const EvalFunction& feval, bool reset = true)
                {
                    this->_init(feval, FirstElem(), reset);

                    acqui_optimizer_t inner_opt;

                    while (this->_samples.size() == 0 || !this->_stop(*this, FirstElem())) {
                        this->template update_pareto_model<EvalFunction::dim_in>();
                        this->update_pareto_data();

                        // copy in the ehvi structure to compute expected improvement
                        std::deque<individual*> pop;
                        for (auto x : this->pareto_data()) {
                            individual* ind = new individual;
                            ind->f[0] = std::get<1>(x)(0);
                            ind->f[1] = std::get<1>(x)(1);
                            ind->f[2] = 0;
                            pop.push_back(ind);
                        }

                        auto acqui = acqui::Ehvi<Params, model_t>(
                            this->_models, pop,
                            Eigen::Vector3d(Params::bayes_opt_ehvi::x_ref(), Params::bayes_opt_ehvi::y_ref(), 0));

                        // maximize with inner opt
                        using pair_t = std::pair<Eigen::VectorXd, double>;
                        pair_t init(Eigen::VectorXd::Zero(1), -std::numeric_limits<float>::max());

                        auto body = [&](int i) -> pair_t {
                            auto x = this->pareto_data()[i];

                            auto acqui_optimization =
                                [&](const Eigen::VectorXd& x, bool g) { return opt::no_grad(acqui(x)); };

                            Eigen::VectorXd s = inner_opt(acqui_optimization, std::get<0>(x), true);
                            double hv = acqui(s);

                            return std::make_pair(s, hv);
                        };

                        auto comp = [](const pair_t& v1, const pair_t& v2) {
                            return v1.second > v2.second;
                        };

                        auto m = tools::par::max(init, this->pareto_data().size(), body, comp);

                        // take the best
                        Eigen::VectorXd new_sample = m.first;

                        // delete pop
                        for (auto x : pop)
                            delete x;

                        // add sample
                        this->add_new_sample(new_sample, feval(new_sample));
                        this->_update_stats(*this, FirstElem());
                        this->_current_iteration++;
                        this->_total_iterations++;
                    }
                }
Example #2
0
                void optimize(const EvalFunction& feval, bool reset = true)
                {
                    this->_init(feval, FirstElem(), reset);

                    while (this->_samples.size() == 0 || !this->_stop(*this, FirstElem())) {
                        std::cout << "updating pareto model...";
                        std::cout.flush();
                        this->template update_pareto_model<EvalFunction::dim_in()>();
                        std::cout << "ok" << std::endl;
                        auto pareto = this->pareto_model();

                        // Pareto front of the variances
                        auto p_variance = pareto::pareto_set<2>(pareto);
                        auto best = p_variance[rand() % p_variance.size()];
                        Eigen::VectorXd best_v = std::get<0>(best);

                        this->add_new_sample(best_v, feval(best_v));
                        std::cout << this->_current_iteration << " | " << best_v.transpose() << "-> "
                                  << this->_observations.back().transpose()
                                  << " (expected:" << this->_models[0].mu(best_v) << " "
                                  << this->_models[1].mu(best_v) << ")"
                                  << " sigma:" << this->_models[0].sigma(best_v) << " "
                                  << this->_models[1].sigma(best_v) << std::endl;
                        this->_update_stats(*this, FirstElem());
                        this->_current_iteration++;
                        this->_total_iterations++;
                    }
                }
Example #3
0
extern eRunStatus node3_Run(	)
{
	Boolean bRunToFinish = true;
	int32 nReady = 1;
	node3_InitVIConstantList();
	{
		heap->e_State_in =node3_in_0_State_in_31;
		heap->l_While_____i = 0;
		do {
			{
				heap->b_Constant = true;
				heap->c_While_____SR_1 = node3_heap_lsr->c_While_____SR;
				heap->b_While_____SR_1 = node3_heap_lsr->b_While_____SR;
				{ /* Select */
					heap->e_State_in_CS = heap->e_State_in;
					switch ( heap->e_State_in_CS ) {
						/* begin case */
						case 0 : {
							/*********************************************************************************/
							/* mod0 \325\375\263\243\262\311\321\371 */
							/* mod1 \275\332\265\347\262\311\321\371 */
							/* mod2 \275\364\274\261\262\311\321\371 */
							/*********************************************************************************/
							{
								heap->n_sampleRate = 5.0000000000000000000E+0;
								heap->e_sampleRateMode = 1;
								heap->n_Range_1 = 3;
								heap->n_Range = 3;
								heap->n_DIO_Drive_Mode_3 = 3;
								heap->n_DIO_Drive_Mode_2 = 3;
								heap->n_DIO_Drive_Mode_1 = 3;
								heap->n_DIO_Drive_Mode = 3;
								heap->l_pow_1 = 100;
								heap->l_mod = 0;
								heap->l_bat = 3;
								heap->l_pow = 100;
								heap->l_sh1 = 35;
								heap->l_sh2 = 40;
								heap->b_Case_Structure_CT = false;
								if ((set_ai_power_Run( 	int32DataType, heap->l_pow_1	)) == eFail) CGenErr();
								{
									heap->by_IO_Channel_Number = 1;
/* Inline C node */
									{
										uInt8 channel = 0;
										uInt16 mode = 0;
										channel = heap->by_IO_Channel_Number;
										mode = heap->n_DIO_Drive_Mode;

										{
											#include "node3_inlineC__71.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->by_IO_Channel_Number_1 = 0;
/* Inline C node */
									{
										uInt8 channel = 0;
										uInt16 mode = 0;
										channel = heap->by_IO_Channel_Number_1;
										mode = heap->n_DIO_Drive_Mode_1;

										{
											#include "node3_inlineC__66.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->by_IO_Channel_Number_2 = 2;
/* Inline C node */
									{
										uInt8 channel = 0;
										uInt16 mode = 0;
										channel = heap->by_IO_Channel_Number_2;
										mode = heap->n_DIO_Drive_Mode_2;

										{
											#include "node3_inlineC__5B.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->by_IO_Channel_Number_3 = 3;
/* Inline C node */
									{
										uInt8 channel = 0;
										uInt16 mode = 0;
										channel = heap->by_IO_Channel_Number_3;
										mode = heap->n_DIO_Drive_Mode_3;

										{
											#include "node3_inlineC__50.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->i_IO_Channel_Number = 1;
/* Inline C node */
									{
										uInt16 range = 0;
										int16 channel = 0;
										range = heap->n_Range;
										channel = heap->i_IO_Channel_Number;

										{
											#include "node3_inlineC__45.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->i_IO_Channel_Number_1 = 0;
/* Inline C node */
									{
										uInt16 range = 0;
										int16 channel = 0;
										range = heap->n_Range_1;
										channel = heap->i_IO_Channel_Number_1;

										{
											#include "node3_inlineC__3A.h"
										}

#undef log
#undef log2
#undef ln
									}
								}
								{
									heap->XNodeTun82 = 0;
/* Inline C node */
									{
										int16 error = 0;
										uInt32 sampleIntervalMode = 0;
										float32 sampleInterval = 0.0;
										error = heap->XNodeTun82;
										sampleIntervalMode = heap->e_sampleRateMode;
										sampleInterval = heap->n_sampleRate;

										{
											#include "node3_inlineC__2F.h"
											heap->XNodeTunB2 = error;
										}

#undef log
#undef log2
#undef ln
									}
								}
/* Bundle by name */
								{
									cl_A0000* cl_001 = NULL;
									/* Cluster CopyOnModify */
									MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____SR_1, sizeof( cl_A0000 ) );
									cl_001 = (cl_A0000*)&heap->c_Case_Structure_CT;
	cl_001->el_0 = heap->l_mod;
	cl_001->el_1 = heap->l_bat;
	cl_001->el_2 = heap->l_pow;
	cl_001->el_3 = heap->l_sh1;
	cl_001->el_4 = heap->l_sh2;
								}
							}
						} /* end case */
						break;
						/* begin case */
						case 1 : {
							{
								MemMove( &heap->c_While_____CT_2, &heap->c_While_____SR_1, sizeof( cl_A0000 ) );
								MemMove( &heap->c_While_____ST, &heap->c_While_____CT_2, sizeof( cl_A0000 ) );
								MemMove( &heap->c_While_____ST_1, &heap->c_While_____CT_2, sizeof( cl_A0000 ) );
								{
									MemMove( &heap->c_While_____ST_3, &heap->c_While_____ST_1, sizeof( cl_A0000 ) );
/* Unbundle by name */
									{
										cl_A0000* cl_002 = (cl_A0000*)&heap->c_While_____ST_3;
										heap->l________________mod = cl_002->el_0;
	}
									{ /* Select */
										heap->l________________mod_CS = heap->l________________mod;
										MemMove( &heap->c_While_____CT_3, &heap->c_While_____ST_3, sizeof( cl_A0000 ) );
										switch ( heap->l________________mod_CS ) {
											/* begin case */
											case 1 : {
												{
													heap->l_times_3 = 10;
													heap->l_times_2 = 10;
													heap->l_delta_1 = 5;
/* Unbundle by name */
													{
														cl_A0000* cl_003 = (cl_A0000*)&heap->c_While_____CT_3;
														heap->l________________sh1_1 = cl_003->el_3;
														heap->l________________sh2_1 = cl_003->el_4;
	}
													{
														extern Boolean sample_a0_out_0_A______1DC_init_;
														Boolean sample_a0_out_0_A______1DC = sample_a0_out_0_A______1DC_init_;
														extern float32 sample_a0_out_1_ai_426_init_;
														float32 sample_a0_out_1_ai_426 = sample_a0_out_1_ai_426_init_;
														heap->b_Case_Structure_CT = sample_a0_out_0_A______1DC_init_;
														heap->n_sample_a0_vi_ai_1 = sample_a0_out_1_ai_426_init_;
														if ((sample_a0_Run( 	int32DataType, heap->l________________sh1_1,
														int32DataType, heap->l_times_3,
														BooleanDataType, &heap->b_Case_Structure_CT,
														floatDataType, &heap->n_sample_a0_vi_ai_1	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI0"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a0_vi_ai_1), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	{
														extern float32 sample_a1_out_0_ai_426_init_;
														float32 sample_a1_out_0_ai_426 = sample_a1_out_0_ai_426_init_;
														heap->n_sample_a1_vi_ai_1 = sample_a1_out_0_ai_426_init_;
														if ((sample_a1_Run( 	int32DataType, heap->l_delta_1,
														int32DataType, heap->l________________sh2_1,
														int32DataType, heap->l_times_2,
														floatDataType, &heap->n_sample_a1_vi_ai_1	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI1"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a1_vi_ai_1), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	}
											} /* end case */
											break;
											/* begin case */
											case 2 : {
												{
													heap->l_times_4 = 1;
													heap->l_times_5 = 1;
													heap->l_delta_2 = 5;
/* Unbundle by name */
													{
														cl_A0000* cl_004 = (cl_A0000*)&heap->c_While_____CT_3;
														heap->l________________sh1_2 = cl_004->el_3;
														heap->l________________sh2_2 = cl_004->el_4;
	}
													{
														extern Boolean sample_a0_out_0_A______1DC_init_;
														Boolean sample_a0_out_0_A______1DC = sample_a0_out_0_A______1DC_init_;
														extern float32 sample_a0_out_1_ai_426_init_;
														float32 sample_a0_out_1_ai_426 = sample_a0_out_1_ai_426_init_;
														heap->b_Case_Structure_CT = sample_a0_out_0_A______1DC_init_;
														heap->n_sample_a0_vi_ai_2 = sample_a0_out_1_ai_426_init_;
														if ((sample_a0_Run( 	int32DataType, heap->l________________sh1_2,
														int32DataType, heap->l_times_4,
														BooleanDataType, &heap->b_Case_Structure_CT,
														floatDataType, &heap->n_sample_a0_vi_ai_2	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI0"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a0_vi_ai_2), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	{
														extern float32 sample_a1_out_0_ai_426_init_;
														float32 sample_a1_out_0_ai_426 = sample_a1_out_0_ai_426_init_;
														heap->n_sample_a1_vi_ai_2 = sample_a1_out_0_ai_426_init_;
														if ((sample_a1_Run( 	int32DataType, heap->l_delta_2,
														int32DataType, heap->l________________sh2_2,
														int32DataType, heap->l_times_5,
														floatDataType, &heap->n_sample_a1_vi_ai_2	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI1"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a1_vi_ai_2), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	}
											} /* end case */
											break;
											/* begin case */
											default : {
												{
													heap->l_times_1 = 3;
													heap->l_times = 3;
													heap->l_delta = 5;
/* Unbundle by name */
													{
														cl_A0000* cl_005 = (cl_A0000*)&heap->c_While_____CT_3;
														heap->l________________sh1 = cl_005->el_3;
														heap->l________________sh2 = cl_005->el_4;
	}
													{
														extern Boolean sample_a0_out_0_A______1DC_init_;
														Boolean sample_a0_out_0_A______1DC = sample_a0_out_0_A______1DC_init_;
														extern float32 sample_a0_out_1_ai_426_init_;
														float32 sample_a0_out_1_ai_426 = sample_a0_out_1_ai_426_init_;
														heap->b_Case_Structure_CT = sample_a0_out_0_A______1DC_init_;
														heap->n_sample_a0_vi_ai = sample_a0_out_1_ai_426_init_;
														if ((sample_a0_Run( 	int32DataType, heap->l________________sh1,
														int32DataType, heap->l_times_1,
														BooleanDataType, &heap->b_Case_Structure_CT,
														floatDataType, &heap->n_sample_a0_vi_ai	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI0"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a0_vi_ai), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	{
														extern float32 sample_a1_out_0_ai_426_init_;
														float32 sample_a1_out_0_ai_426 = sample_a1_out_0_ai_426_init_;
														heap->n_sample_a1_vi_ai = sample_a1_out_0_ai_426_init_;
														if ((sample_a1_Run( 	int32DataType, heap->l_delta,
														int32DataType, heap->l________________sh2,
														int32DataType, heap->l_times,
														floatDataType, &heap->n_sample_a1_vi_ai	)) == eFail) CGenErr();
													}
													{
														static uInt32 id = 0;
														static NetworkVariableAttrs attrs = { 
															/* url */ _LVT("\\\\169.254.62.215\\Node1\\AI1"), 
															/* alias */ _LVT("VISN-WSN"), 
															/* buffering */ true, 
															/* buffer size limit */ 800 /* 0x320 */, 
															/* buffer value limit */ 50 /* 0x32 */
														};
														if (!NetworkVariableWrite(&id, attrs, NULL, &(heap->n_sample_a1_vi_ai), floatDataType, floatDataType, NULL)) {
															CGenErr();
														}
													}
	}
											} /* end case */
											break;
										}
									} /* end switch */
									/**/
									/* 等于? */
									/**/
									heap->b________x___y_ =  (heap->b_Case_Structure_CT == heap->b_While_____SR_1);
									{ /* Select */
										heap->b________x___y__CS = heap->b________x___y_;
										/* begin case */
										if ( heap->b________x___y__CS ) {
											{
												MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____ST, sizeof( cl_A0000 ) );
											}
										} /* end case */
										/* begin case */
										else {
											{
												{ /* Select */
													heap->b__________CS = heap->b_Case_Structure_CT;
													/* begin case */
													if ( heap->b__________CS ) {
														/*********************************************************************************/
														/* \275\370\310\353\276\257\261\250\304\243\312\275 */
														/*********************************************************************************/
														{
															heap->l_mod_2 = 2;
															heap->n_sampleInterval_1 = 1.0000000000000000000E+0;
															heap->b_bell_1 = true;
															{
																heap->n_Constant_1 = 0;
																{
																	heap->by_t_1 = 1;
																	heap->by_f_1 = 0;
																	/**/
																	/* 选择 */
																	/**/
																	if (heap->b_bell_1) {
																		heap->by______s__t_f_1 = heap->by_t_1;
	}
																	else {
																		heap->by______s__t_f_1 = heap->by_f_1;
	}
/* Inline C node */
																	{
																		uInt8 value = 0;
																		int8 unusedInput = 0;
																		value = heap->by______s__t_f_1;
																		unusedInput = heap->n_Constant_1;

																		{
																			#include "node3_inlineC__EA.h"
																		}

#undef log
#undef log2
#undef ln
																	}
																}
																{
/* Inline C node */
																	{
																		int8 unusedInput = 0;
																		unusedInput = heap->n_Constant_1;

																		{
																			#include "node3_inlineC__EC.h"
																		}

#undef log
#undef log2
#undef ln
																	}
																}
															}
															{
																heap->XNodeTun1B01 = 0;
/* Inline C node */
																{
																	int16 error = 0;
																	float32 sampleInterval = 0.0;
																	error = heap->XNodeTun1B01;
																	sampleInterval = heap->n_sampleInterval_1;

																	{
																		#include "node3_inlineC__D6.h"
																		heap->XNodeTun1B16 = error;
																	}

#undef log
#undef log2
#undef ln
																}
															}
/* Bundle by name */
															{
																cl_A0000* cl_006 = NULL;
																/* Cluster CopyOnModify */
																MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____ST, sizeof( cl_A0000 ) );
																cl_006 = (cl_A0000*)&heap->c_Case_Structure_CT;
	cl_006->el_0 = heap->l_mod_2;
															}
														}
													} /* end case */
													/* begin case */
													else {
														{
															heap->n_sampleInterval = 5.0000000000000000000E+0;
															heap->l_mod_1 = 0;
															heap->b_bell = false;
															{
																heap->n_Constant = 0;
																{
																	heap->by_t = 1;
																	heap->by_f = 0;
																	/**/
																	/* 选择 */
																	/**/
																	if (heap->b_bell) {
																		heap->by______s__t_f = heap->by_t;
	}
																	else {
																		heap->by______s__t_f = heap->by_f;
	}
/* Inline C node */
																	{
																		uInt8 value = 0;
																		int8 unusedInput = 0;
																		value = heap->by______s__t_f;
																		unusedInput = heap->n_Constant;

																		{
																			#include "node3_inlineC__C8.h"
																		}

#undef log
#undef log2
#undef ln
																	}
																}
																{
/* Inline C node */
																	{
																		int8 unusedInput = 0;
																		unusedInput = heap->n_Constant;

																		{
																			#include "node3_inlineC__CA.h"
																		}

#undef log
#undef log2
#undef ln
																	}
																}
															}
															{
																heap->XNodeTun2A50 = 0;
/* Inline C node */
																{
																	int16 error = 0;
																	float32 sampleInterval = 0.0;
																	error = heap->XNodeTun2A50;
																	sampleInterval = heap->n_sampleInterval;

																	{
																		#include "node3_inlineC__B3.h"
																		heap->XNodeTun2A65 = error;
																	}

#undef log
#undef log2
#undef ln
																}
															}
/* Bundle by name */
															{
																cl_A0000* cl_007 = NULL;
																/* Cluster CopyOnModify */
																MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____ST, sizeof( cl_A0000 ) );
																cl_007 = (cl_A0000*)&heap->c_Case_Structure_CT;
	cl_007->el_0 = heap->l_mod_1;
															}
														}
													} /* end case */
												} /* end switch */
											}
										} /* end case */
									} /* end switch */
								}
								/* FreeLoopInputs. */
		/* FreeLoopInputs. */
	}
						} /* end case */
						break;
						/* begin case */
						case 2 : {
							{
								/*********************************************************************************/
								/* \311\350\326\303\304\243\312\275\241\242\262\311\321\371\274\344\270\364\241\242\264\253\270\320\306\367\265\347\324\264\321\241\317\356\241\242\301\275\270\366\264\253\270\320\306\367\343\320\326\265 */
								/* mod0\316\252\327\324\266\250\322\345\304\243\312\275\243\254\270\337\313\331\317\324\312\276\304\243\312\275 */
								/* mod1\316\252\275\332\265\347\324\313\320\320\304\243\312\275 */
								/*********************************************************************************/
								/*********************************************************************************/
								/* setmod0-1 */
								/*********************************************************************************/
								/*********************************************************************************/
								/* redint */
								/*********************************************************************************/
								/*********************************************************************************/
								/* setpow10 */
								/*********************************************************************************/
								{
									{
										heap->XNodeTun144C = 0;
										heap->i_Constant = 0;
										heap->by_Constant = 0;
										heap->i_Constant_1 = 127;
/* Array initialize */
										{
											ArrDimSize i;
											ArrDimSize size=1;
											heap->a________________________ = PDAArrNew1D((ArrDimSize)heap->i_Constant_1, uCharDataType);
											size = (ArrDimSize)heap->i_Constant_1;
											if (size < 0) {
												size = 0;
											}
											if (IsNotZero(&heap->by_Constant, uCharDataType)) {
												MemSet(FirstElem(heap->a________________________), size, heap->by_Constant);
											}
	}
/* Inline C node */
										{
											int16 error = 0;
											PDAArrPtr receivedUserMessage_nodeTempArrayHandle = NULL;
											uInt8* receivedUserMessage = NULL;
											int16 receivedUserMessageLength = 0;
											error = heap->XNodeTun144C;
											receivedUserMessage_nodeTempArrayHandle=PDAArrCopyOnModify( heap->a________________________ );
											receivedUserMessage = (VoidHand)FirstElem(receivedUserMessage_nodeTempArrayHandle);
											receivedUserMessageLength = heap->i_Constant;

											{
												#include "node3_inlineC__105.h"
												heap->XNodeTun1450 = error;
												heap->a_____C_____________ = receivedUserMessage_nodeTempArrayHandle;
												heap->i_____C______________4 = receivedUserMessageLength;
											}

#undef log
#undef log2
#undef ln
										}
										/* Array Subset */
										{
											Boolean bEmpty = false;
											Boolean bNullInput=false;
											ArrDimSize start0;
											if (!heap->a_____C_____________) {heap->a_____C_____________ = PDAArrNewEmptyWithNDims( uCharDataType, (ArrDimSize)1 );bNullInput=true;}
											{
												ArrDimSize nDimSize0=0;
												start0 = (ArrDimSize)0;
												if (start0 < 0) {
													start0 = 0;
												}

												if (start0 >= PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0)) {
													start0 = PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0);
												}
												nDimSize0 = (ArrDimSize)heap->i_____C______________4;
												if (nDimSize0 <= 0) {
													nDimSize0 = 0;
												}
												if ((start0 + nDimSize0) > PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0)) {
													nDimSize0 = PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0) - start0;
												}
												if (!(heap->a________________ = PDAArrNew1D((ArrDimSize)nDimSize0, uCharDataType))){
													CGenErr();
												}
											}
											{
												ArrDimSize end0;
												if (start0 >= PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0)) {
													bEmpty = true;
												}
												end0 = start0 + (ArrDimSize)heap->i_____C______________4;
												if ((end0 < 0) || (end0 <= start0)) {
													bEmpty = true;	}
												if (end0 > PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0)) {
													end0 = PDAArrNthDim(heap->a_____C_____________, (ArrDimSize)0);
													PDAArrSetDim(heap->a________________, (ArrDimSize)0, (end0 - start0) );
												}
												if (!bEmpty) {
													MemMove(NthElem(heap->a________________, 0), NthElem(heap->a_____C_____________, start0), (end0-start0)*DataSize(uCharDataType));
												}
												else {
													MemHandleFree( heap->a________________ ); //  Uninitialized
													if (!(heap->a________________ = PDAArrNewEmptyWithNDims( uCharDataType, (ArrDimSize)1 ))) CGenErr();
												}
	if ((heap->a_____C_____________) && ((heap->a_____C_____________)->refcnt > 0)) {
													if (((heap->a_____C_____________)->refcnt == 1) && ((heap->a_____C_____________)->staticArray == false)) {
														(heap->a_____C_____________)->refcnt--;
														MemHandleFree( heap->a_____C_____________ );
														heap->a_____C_____________=NULL;
													}
													else
													 	PDAArrFree(heap->a_____C_____________);
												}
											}
											if (bNullInput) heap->a_____C_____________ = NULL;
										}
										/**/
										/* 字节数组至字符串转换 */
										/**/
										if (!PDAArrToString(heap->a________________, &(heap->XNodeTun1454))) {
											CGenErr();
										}
									}
									heap->s_____________________________X = heap->XNodeTun1454;
									PDAStrIncRefCnt(heap->s_____________________________X, (uInt16)2); /* XNode: tunnel list */
									{
										extern cl_A0000 set_red_state_out_0_set_24A_init_;
										cl_A0000 set_red_state_out_0_set_24A = set_red_state_out_0_set_24A_init_;
										heap->c_set_red_state_vi_set_ST_1 = set_red_state_out_0_set_24A;
										if ((set_red_state_Run( 	StringDataType, heap->s_____________________________X,
										0xA0000 | ClusterDataType, heap->c_While_____SR_1,
										0xA0000 | ClusterDataType, &heap->c_set_red_state_vi_set_ST_1	)) == eFail) CGenErr();
									}
									if ((message_dio_control_Run( 	StringDataType, heap->s_____________________________X	)) == eFail) CGenErr();
									heap->s_____________________________S = heap->s_____________________________X;
								}
								/* FreeLoopInputs. */
	{
									heap->s_____________________________S_1 = heap->s_____________________________S;
									PDAStrIncRefCnt(heap->s_____________________________S_1, (uInt16)1); /* SequenceTunnel */
									MemMove( &heap->c_set_red_state_vi_set_ST_5, &heap->c_set_red_state_vi_set_ST_1, sizeof( cl_A0000 ) );
/* Unbundle by name */
									{
										cl_A0000* cl_008 = (cl_A0000*)&heap->c_set_red_state_vi_set_ST_5;
										heap->l________________mod_1 = cl_008->el_0;
	}
									{ /* Select */
										heap->l________________mod_CS_1 = heap->l________________mod_1;
										MemMove( &heap->c_set_red_state_vi_set_CT, &heap->c_set_red_state_vi_set_ST_5, sizeof( cl_A0000 ) );
										/* begin case */
										if ( ( (heap->l________________mod_CS_1 == 1) ) ) {
											{
												heap->n_sampleInterval_3 = 6.0000000000000000000E+1;
												heap->l_pow_2 = 100;
												/* Free unwired input select tunnel. */
	if ((set_ai_power_Run( 	int32DataType, heap->l_pow_2	)) == eFail) CGenErr();
												{
													heap->XNodeTunE47 = 0;
/* Inline C node */
													{
														int16 error = 0;
														float32 sampleInterval = 0.0;
														error = heap->XNodeTunE47;
														sampleInterval = heap->n_sampleInterval_3;

														{
															#include "node3_inlineC__124.h"
															heap->XNodeTunE5C = error;
														}

#undef log
#undef log2
#undef ln
													}
												}
											}
										} /* end case */
										/* begin case */
										else {
											{
												heap->n_sampleInterval_2 = 5.0000000000000000000E+0;
												{
													heap->XNodeTunDD7 = 0;
/* Inline C node */
													{
														int16 error = 0;
														float32 sampleInterval = 0.0;
														error = heap->XNodeTunDD7;
														sampleInterval = heap->n_sampleInterval_2;

														{
															#include "node3_inlineC__118.h"
															heap->XNodeTunDF6 = error;
														}

#undef log
#undef log2
#undef ln
													}
												}
/* Unbundle by name */
												{
													cl_A0000* cl_009 = (cl_A0000*)&heap->c_set_red_state_vi_set_CT;
													heap->l________________pow = cl_009->el_2;
	}
												if ((set_ai_power_Run( 	int32DataType, heap->l________________pow	)) == eFail) CGenErr();
											}
										} /* end case */
									} /* end switch */
									MemMove( &heap->c_Case_Structure_CT, &heap->c_set_red_state_vi_set_ST_5, sizeof( cl_A0000 ) );
								}
								/* FreeLoopInputs. */
	if (heap->s_____________________________S && (((PDAStrPtr)heap->s_____________________________S)->refcnt > 0)) {
									if ((--((PDAStrPtr)heap->s_____________________________S)->refcnt == 0) && (!((PDAStrPtr)heap->s_____________________________S)->staticStr)) {
										MemHandleFree( heap->s_____________________________S );
										heap->s_____________________________S=NULL;
									}
								}
								/* FreeLoopInputs. */
	{
									node3_GlobalConstantsHeapPtr->i83B = PDAStrNewFromBuf(_LVT("received: "),(uInt32)10);
									heap->s_Constant = node3_GlobalConstantsHeapPtr->i83B;
									PDAStrIncRefCnt(heap->s_____________________________S_1, (uInt16)1); /* SequenceTunnel */
									{
										ControlDataItemPtr cdPtr = LVGetCurrentControlData();
										CreateArgListStatic(heap->Args82F_1, 2, 1 );
										argIn(heap->Args82F_1, 0).nType = StringDataType;
										argIn(heap->Args82F_1, 0).pValue = (void *)&heap->s_Constant;
										argIn(heap->Args82F_1, 1).nType = StringDataType;
										argIn(heap->Args82F_1, 1).pValue = (void *)&heap->s_____________________________S_1;
										argOut(heap->Args82F_1, 0).nType = StringDataType;
										argOut(heap->Args82F_1, 0).pValue = (void *)&heap->s________________________;
										if (!PDAStrConcat( (ArgList *)((ArgList **)heap->Args82F_1)[0], (ArgList *)((ArgList **)heap->Args82F_1)[1] )) {
											CGenErr();
										}
										if (gAppStop) {
											gAppStop=true;
											return eFinished;
										}
									}
									{
										heap->XNodeTun84A = 0;
										heap->s_________________________XT = heap->s________________________;
										PDAStrIncRefCnt(heap->s_________________________XT, (uInt16)1); /* FrameTunnel */
										/**/
										/* 字符串长度 */
										/**/
										heap->l________________ = (int32)PDAStrLen(heap->s_________________________XT);
										/**/
										/* 字符串至字节数组转换 */
										/**/
										if (!PDAStrToArray(heap->s_________________________XT, &(heap->a______________________________))) {
											CGenErr();
										}
/* Inline C node */
										{
											int16 error = 0;
											PDAArrPtr sendDebugMessage_nodeTempArrayHandle = NULL;
											uInt8* sendDebugMessage = NULL;
											int32 sendDebugMessageLength = 0;
											error = heap->XNodeTun84A;
											sendDebugMessage_nodeTempArrayHandle=PDAArrCopyOnModify( heap->a______________________________ );
											sendDebugMessage = (VoidHand)FirstElem(sendDebugMessage_nodeTempArrayHandle);
											sendDebugMessageLength = heap->l________________;

											{
												#include "node3_inlineC__130.h"
												heap->XNodeTun84E = error;
											}

											/* Free input array without corresponding output in inline C node */
	if ((sendDebugMessage_nodeTempArrayHandle) && ((sendDebugMessage_nodeTempArrayHandle)->refcnt > 0)) {
												if (((sendDebugMessage_nodeTempArrayHandle)->refcnt == 1) && ((sendDebugMessage_nodeTempArrayHandle)->staticArray == false)) {
													(sendDebugMessage_nodeTempArrayHandle)->refcnt--;
													MemHandleFree( sendDebugMessage_nodeTempArrayHandle );
													sendDebugMessage_nodeTempArrayHandle=NULL;
												}
												else
												 	PDAArrFree(sendDebugMessage_nodeTempArrayHandle);
											}
#undef log
#undef log2
#undef ln
										}
									}
								}
								/* FreeLoopInputs. */
	if (heap->s_____________________________S_1 && (((PDAStrPtr)heap->s_____________________________S_1)->refcnt > 0)) {
									if ((--((PDAStrPtr)heap->s_____________________________S_1)->refcnt == 0) && (!((PDAStrPtr)heap->s_____________________________S_1)->staticStr)) {
										MemHandleFree( heap->s_____________________________S_1 );
										heap->s_____________________________S_1=NULL;
									}
								}
								heap->b_Case_Structure_CT = heap->b_While_____SR_1;
							}
						} /* end case */
						break;
						/* begin case */
						case 3 : {
							{
								MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____SR_1, sizeof( cl_A0000 ) );
								{
									heap->XNodeTun10B = 0;
									heap->e_Network_Status = 0;
/* Inline C node */
									{
										int16 error = 0;
										uInt32 networkStatus = 0;
										error = heap->XNodeTun10B;
										networkStatus = heap->e_Network_Status;

										{
											#include "node3_inlineC__13B.h"
											heap->XNodeTunC63 = error;
											heap->e_____C______________XT = networkStatus;
										}

#undef log
#undef log2
#undef ln
									}
								}
								{ /* Select */
									heap->e_____C______________CS = heap->e_____C______________XT;
									/* begin case */
									if ( ( (heap->e_____C______________CS == 1) ) ) {
										{
											node3_GlobalConstantsHeapPtr->i23A = PDAStrNewFromBuf(_LVT("Node connected ..."),(uInt32)18);
											heap->s_sendDebugMessage = node3_GlobalConstantsHeapPtr->i23A;
											{
												heap->XNodeTun24B = 0;
												heap->s_sendDebugMessage_XT = heap->s_sendDebugMessage;
												PDAStrIncRefCnt(heap->s_sendDebugMessage_XT, (uInt16)1); /* FrameTunnel */
												/**/
												/* 字符串长度 */
												/**/
												heap->l_________________1 = (int32)PDAStrLen(heap->s_sendDebugMessage_XT);
												/**/
												/* 字符串至字节数组转换 */
												/**/
												if (!PDAStrToArray(heap->s_sendDebugMessage_XT, &(heap->a_______________________________1))) {
													CGenErr();
												}
/* Inline C node */
												{
													int16 error = 0;
													PDAArrPtr sendDebugMessage_nodeTempArrayHandle = NULL;
													uInt8* sendDebugMessage = NULL;
													int32 sendDebugMessageLength = 0;
													error = heap->XNodeTun24B;
													sendDebugMessage_nodeTempArrayHandle=PDAArrCopyOnModify( heap->a_______________________________1 );
													sendDebugMessage = (VoidHand)FirstElem(sendDebugMessage_nodeTempArrayHandle);
													sendDebugMessageLength = heap->l_________________1;

													{
														#include "node3_inlineC__148.h"
														heap->XNodeTun251 = error;
													}

													/* Free input array without corresponding output in inline C node */
	if ((sendDebugMessage_nodeTempArrayHandle) && ((sendDebugMessage_nodeTempArrayHandle)->refcnt > 0)) {
														if (((sendDebugMessage_nodeTempArrayHandle)->refcnt == 1) && ((sendDebugMessage_nodeTempArrayHandle)->staticArray == false)) {
															(sendDebugMessage_nodeTempArrayHandle)->refcnt--;
															MemHandleFree( sendDebugMessage_nodeTempArrayHandle );
															sendDebugMessage_nodeTempArrayHandle=NULL;
														}
														else
														 	PDAArrFree(sendDebugMessage_nodeTempArrayHandle);
													}
#undef log
#undef log2
#undef ln
												}
											}
										}
									} /* end case */
									/* begin case */
									else {
										{
										}
									} /* end case */
								} /* end switch */
								heap->b_Case_Structure_CT = heap->b_While_____SR_1;
							}
						} /* end case */
						break;
						/* begin case */
						case 4 : {
							{
								MemMove( &heap->c_Case_Structure_CT, &heap->c_While_____SR_1, sizeof( cl_A0000 ) );
								heap->b_Case_Structure_CT = heap->b_While_____SR_1;
							}
						} /* end case */
						break;
					}
				} /* end switch */
				MemMove( &heap->c_Case_Structure_SR, &heap->c_Case_Structure_CT, sizeof( cl_A0000 ) );
				MemMove(&node3_heap_lsr->c_While_____SR, &heap->c_Case_Structure_SR, sizeof(cl_A0000));
				heap->b_Case_Structure_SR = heap->b_Case_Structure_CT;
				node3_heap_lsr->b_While_____SR = heap->b_Case_Structure_SR;
			}
			(heap->l_While_____i)++;
		}
		while(!heap->b_Constant && !gAppStop && !gLastError);
		node3_CleanupVIGlobalConstants();
		return eFinished;
	}
}