发表于:2003-04-21 09:52:00
1楼
//{{NodeBuilder Code Wizard Start <CodeWizard Timestamp>
// Run on Tue Aug 20 15:50:25 2002, version 3.00.52
//
//}}NodeBuilder Code Wizard End
//////////////////////////////////////////////////////////////////////////////
// File: dimmer.nc
//
//
// Generated by NodeBuilder Code Wizard Version 3.00.52
// Copyright ?2001 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:
//////////////////////////////////////////////////////////////////////////////
#ifndef _dimmer_NC_
#define _dimmer_NC_
/////////////////////////////////////////////////////////////////////////////
// Header Files
//
#include "dimmer.h"
#include "common.h"
// define file directory
#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>
//
//<Include Headers>
//
//<Device CP Family Declarations>
//
//<Device CP Declarations>
//
//<Device Input NV Declarations>
//
//<Device Output NV Declarations>
//
// <Include NC>
//
//}}NodeBuilder Code Wizard End
/////////////////////////////////////////////////////////////////////////////
// Neuron C Files
//
//{{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>
#ifdef _HAS_INP_DEV_NV
//
//<Device NV When>
//
//}}NodeBuilder Code Wizard End
{
// TODO: Add code to handle input network variable processing
}
#endif //_HAS_INPUT_NV_
network input SNVT_switch nviLampValue;
network output SNVT_switch nvoSwitch;
IO_0 output triac pulse sync(IO_5) invert clockedge(+-) ioDimmer;
const unsigned long MIN_BRIGHTNESS = 400;
const unsigned long MAX_BRIGHTNESS = 0 ;
const unsigned long ON = 1;
signed long currentBrightness;
signed long setBrightness;
/////////////////////////////////////////////////////////////////////////////
// Execute system/scheduler commands when they occur
//
when (reset)
{
io_out(ioDimmer,MAX_BRIGHTNESS);
currentBrightness = MAX_BRIGHTNESS;
}
when (offline)
{
}
when (online)
{
}
when (wink)
{
// TODO: Add appropriate wink behavior here
}
when (nv_update_occurs)
{
nvoSwitch = nviLampValue;
setBrightness = nviLampValue.value;
if (nviLampValue.state == 1) currentBrightness= 400 - 2 * setBrightness;
else currentBrightness = 400;
io_out(ioDimmer,currentBrightness);
}
#endif // _dimmer_NC_
//{{NodeBuilder Code Wizard Start <CodeWizard Timestamp>
// Run on Tue Aug 20 15:50:25 2002, version 3.00.52
//
//}}NodeBuilder Code Wizard End
//////////////////////////////////////////////////////////////////////////////
// File: dimmer.H
//
//
// Generated by NodeBuilder Code Wizard Version 3.00.52
// Copyright ?2001 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:
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _dimmer_H_
#define _dimmer_H_
// Configuration parameters storage.
#define CP_STORAGE far offchip eeprom
#define CP_CONST_STORAGE far offchip eeprom
// Functional blocks need to store non-volatile state variables
#define FBLOCK_PERSISTENT_STATUS_STORAGE onchip eeprom
// Some variables do not need to be saved across reset
#define FBLOCK_STATUS_STORAGE far
//
//{{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
// <CP Access>
#define _USE_NO_CPARAMS_ACCESS
//
//<Node Description String>
//
//<External Name>
#define USE_EXTERNAL_NAME
//
//<Fblock Counts>
#define NodeObject_FBLOCK_COUNT 1
#define switch1_FBLOCK_COUNT 1
#define lampActuator_FBLOCK_COUNT 1
//
//<Total Fblock Count>
#define TOTAL_FBLOCK_COUNT NodeObject_FBLOCK_COUNT + switch1_FBLOCK_COUNT + lampActuator_FBLOCK_COUNT
//
//<File List>
// Implements Filename
// NB Device Template: dimmer.nc
// dimmer.h
// Common Functions: c:\lm\Source\dimmer\dimmer\common.h
// c:\lm\Source\dimmer\dimmer\common.nc
// c:\lm\Source\dimmer\dimmer\Filesys.h
// Node Object: c:\lm\Source\dimmer\dimmer\NodeObject.nc
// c:\lm\Source\dimmer\dimmer\NodeObject.h
// FBlock: c:\lm\Source\dimmer\dimmer\switch1.nc
// c:\lm\Source\dimmer\dimmer\switch1.h
// c:\lm\Source\dimmer\dimmer\lampActuator.nc
// c:\lm\Source\dimmer\dimmer\lampActuator.h
//
//}}NodeBuilder Code Wizard End
// The file directory has:
// The template file, the value file, and the constant value file by
// default. If you add user-defined files, adjust NUM_FILES
// accordingly
#define NUM_FILES 3
// The following code will be ignored if this Neuron C file is used
// as a ShortStack Neuron C model file, because the expressions
// within the following #ifndef/#endif pair are not accepted
// when compiling a ShortStack Neuron C model file.
// See www.echelon.com/shortstack for more information on the
// ShortStack products.
#ifndef _SHORTSTACK
//{{NodeBuilder Code Wizard Start <Alias Entries>
#pragma num_alias_table_entries 11
//
//}}NodeBuilder Code Wizard End
///
// If all configuration properties are implemented with
// configuration network variables, instead of configuration
// parameters, you may choose to include FTP support for user_defined
// purpose allowing transfer of user-defined files. You will need to
// explicitly initialize the file directory in this case.
// #define _INCLUDE_FTP
// Set address table size to maximum (15 entries). You may reduce the
// size of the address table as described in the Neuron C documentation,
// however, it is highly recommended to maximize the size of the
// address table as resources allow.
#pragma num_addr_table_entries 15
#endif // _shortstack
#endif // _dimmer_H_