⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gw.nc

📁 这是应用SAM7X256做LonWorks网关的代码
💻 NC
字号:
//{{NodeBuilder Code Wizard Start <CodeWizard Timestamp>
// Run on Fri Dec 28 21:24:20 2007, version 3.10.56
//
//}}NodeBuilder Code Wizard End

//////////////////////////////////////////////////////////////////////////////
// File: gw.nc 
//
//
// Generated by NodeBuilder Code Wizard Version 3.10.56
// Copyright (c) 2001-2003 Echelon Corporation.  All rights reserved.
//                                                                                  
// ECHELON MAKES NO REPRESENTATION, WARRANTY, OR CONDITION OF
// ANY KIND, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE OR IN
// ANY COMMUNICATION WITH YOU, INCLUDING, BUT NOT LIMITED TO,
// ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY
// QUALITY, FITNESS FOR ANY PARTICULAR PURPOSE, 
// NONINFRINGEMENT, AND THEIR EQUIVALENTS.
//
//
//  Written By:   
//
//	Description:
//
//	gw.nc is the device's main Neuron C source file.
//	It contains the declaration of the system tasks (when(reset), 
//	etc), and it contains the declaration of the file directory.
//	It includes all other Neuron C source or header files as needed.
//////////////////////////////////////////////////////////////////////////////

#ifndef _gw_NC_
#define _gw_NC_

/////////////////////////////////////////////////////////////////////////////
// Header Files 
//
#include "gw.h"
#include "common.h"

// FileDirectory is a variable that contains the file directory. Please see filexfer.h
// and filesys.h for more details about the implementation of the file system and the 
// file transfer protocol. 
// Note a file directory must be defined whenever at least one configuration parameter
// in files is defined or at least one user-defined file exists. A file directory must
// be defined independent of the CP access mechanism (file transfer or direct access),
// but note a different layout of file directory will be compiled for each of these
// access mechanism. The two access techniques are mutually exclusive. 
#ifndef _USE_NO_CPARAMS_ACCESS
	DIRECTORY_STORAGE TFileDirectory FileDirectory = {
    	FILE_DIRECTORY_VERSION,   // major and minor version number (one byte)
	    NUM_FILES, {
	#ifdef _USE_DIRECT_CPARAMS_ACCESS
			{ cp_template_file_len,         TEMPLATE_TYPE,	cp_template_file },
			{ cp_modifiable_value_file_len, VALUE_TYPE,		cp_modifiable_value_file },
			{ cp_readonly_value_file_len,   VALUE_TYPE,		cp_readonly_value_file   }
	#else	// def. _USE_FTP_CPARAMS_ACCESS
			{ NULL_INFO, { 0ul, cp_template_file_len	},		TEMPLATE_TYPE, 	cp_template_file },
			{ NULL_INFO, { 0ul, cp_modifiable_value_file_len },	VALUE_TYPE, 	cp_modifiable_value_file },
			{ NULL_INFO, { 0ul, cp_readonly_value_file_len },	VALUE_TYPE,		cp_readonly_value_file }
	#endif	// def. _USE_DIRECT_CPARAMS_ACCESS
		}
	};
#endif // def. _USE_NO_CPARAMS_ACCESS


//{{NodeBuilder Code Wizard Start
// The NodeBuilder Code Wizard will add and remove code here.
// DO NOT EDIT the NodeBuilder Code Wizard generated code in these blocks 
// between {{NodeBuilder Code Wizard Start and }}NodeBuilder Code Wizard End

//<Include Enum Type Headers>
//
//<Global CP Family Declarations>
//
//<Include Headers>
#include "NodeObject.h"
//
//<Device CP Family Declarations>
//
//<Device CP Declarations>
//
//<Device Input NV Declarations>
//
//<Device Output NV Declarations>
//
// <Include NC>
#include "NodeObject.nc"
//
//}}NodeBuilder Code Wizard End


/////////////////////////////////////////////////////////////////////////////
// Neuron C Files 
// 
#include "common.nc"

#ifdef _USE_FTP_CPARAMS_ACCESS
	#include "fileSys.nc"
	#include "fileXfer.nc"
#endif 

//{{NodeBuilder Code Wizard Start
// The NodeBuilder Code Wizard will add and remove code here.
// DO NOT EDIT the NodeBuilder Code Wizard generated code in these blocks!
 
//<Input NV>
//
//}}NodeBuilder Code Wizard End

//{{NodeBuilder Code Wizard Start 
// The NodeBuilder Code Wizard will add and remove code here.
// DO NOT EDIT the NodeBuilder Code Wizard generated code in these blocks!

//<Input NV Define>
//
// The following code will be ignored if this Neuron C file is used without
// an input NV implemented.  The Code Wizard automatically enables 
// the _HAS_INP_DEV_NV macro if there is at least one input NV implemented.
//
#ifdef _HAS_INP_DEV_NV
//
//<Device NV When>
//
//}}NodeBuilder Code Wizard End
{
	// TODO: Add code to handle input network variable processing
}
#endif	//_HAS_INP_DEV_NV


/////////////////////////////////////////////////////////////////////////////
// Execute system/scheduler commands when they occur 
// 
// 	when(reset) gets executed any time the device is reset. Make sure to keep
//	your when(reset) task as short as possible, as a pending state change can
//	not be confirmed until this task is completed. Note the default Code Wizard 
// 	framework does not contain code to refresh the Neuron's watchdog timer. 
// 	On devices that contain a large number of fblocks, this might result in a
//	watchdog-timer reset during reset processing. 
//	Unless code changes to the framework and the default directors allow to 
//	overcome this problem, calls to the watchdog_update() function should be 
//	inserted in the executeOnEachFblock() function.
when (reset)
{
	initAllFblockData();
	executeOnEachFblock(FBC_WHEN_RESET);
}

//	when(offline) gets executed as the device enters the offline state.
// 	Make sure to keep this task as short as possible as the state change
//	can not be confirmed until this task is completed. Note the default Code Wizard 
// 	framework does not contain code to refresh the Neuron's watchdog timer. 
// 	On devices that contain a large number of fblocks, this might result in a
//	watchdog-timer reset during reset processing. 
//	Unless code changes to the framework and the default directors allow to 
//	overcome this problem, calls to the watchdog_update() function should be 
//	inserted in the executeOnEachFblock() function.
when (offline)
{
	executeOnEachFblock(FBC_WHEN_OFFLINE);
}

//	when(online) gets executed as the device enters the online state.
// 	Make sure to keep this task as short as possible as the state change
//	can not be confirmed until this task is completed. Note the default Code Wizard 
// 	framework does not contain code to refresh the Neuron's watchdog timer. 
// 	On devices that contain a large number of fblocks, this might result in a
//	watchdog-timer reset during reset processing. 
//	Unless code changes to the framework and the default directors allow to 
//	overcome this problem, calls to the watchdog_update() function should be 
//	inserted in the executeOnEachFblock() function.
when (online)
{
	executeOnEachFblock(FBC_WHEN_ONLINE);
}

//	when(wink) gets executed as the device recieves a wink command. This should be
// 	used to generate some appropriate, harmless but noticeable, action such as the 
// 	brief flashing of an LED. The purpose of the wink command is to allow for a device
// 	to be visually identified amongst others, where the command is generated by some 
// 	network management tool. Remember the wink command can occur at any state, even
//	when the device is in the unconfigured state. Application timers and other features
//	that require a particular device state shall therefore not be used for the
//	implementation of a wink command handler. 
//	Further more, note the wink command is typically used to identify the device. 
//	The response should therefore not impact the network, consist of a visual or 
//	audible signal, and should by no means cause harm to or by machinery that is
//	attached to the device.
when (wink)
{
	// TODO: Implement appropriate wink behavior here

}


#ifdef _HAS_CHANGEABLE_NV
        
// The _HAS_CHANGEABLE_NV macro will be defined by Code Wizard
// when at least one network variable with changeable type is
// being implemented. The conditional compilation here
// provides the callback routine that is used to report the
// the true and current length of a given network variable
// back to the firmware.
// Code Wizard also enables the callback by inserting the
// system_image_extensions pragma, see gw.h
// Note that callback support requires firmware version 14
// or better.
unsigned get_nv_length_override(unsigned nvIndex)
{
	unsigned uResult;
	
	// Assume no override
	uResult = 0xFF;

	// TO DO: add code to return the current length of
	// the network variable with index "nvIndex." 
	// For example:
	// switch (nvIndex) {
	//     case nviChangeableNv::global_index:
	//         if (nviChangeableNv::cpNvType.type_category != NVT_CAT_INITIAL
	//          && nviChangeableNv::cpNvType.type_category != NVT_CAT_NUL) {
	//             uResult = nviChangeableNv::cpNvType.type_length;
	//         }
	//         break; 
	// }

	return uResult;
}

#endif	// #ifdef _HAS_CHANGEABLE_NV


#endif // _gw_NC_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -