0

用SIMPL+写了一个设备的控制宏,信号触发的时候宏没有输出指令,无法控制设备。

主机AV3(1.010.0060)

宏代码如下:


/*******************************************************************************************
SIMPL+ Module Information
(Fill in comments below)
*******************************************************************************************/
/*
Dealer Name:CrestronAsia(GZ)
System Name:
System Number:
Programmer:Oliver Huang
Comments:
*/

/*******************************************************************************************
Compiler Directives
(Uncomment and declare compiler directives as needed)
*******************************************************************************************/
// #ENABLE_DYNAMIC
#SYMBOL_NAME "MUSICROWN-AK800-v1"
// #HINT ""
#DEFINE_CONSTANT MaxNum 10
#CATEGORY "28" // Receiver/Processor
// #PRINT_TO_TRACE
// #DIGITAL_EXPAND
// #ANALOG_SERIAL_EXPAND
// #OUTPUT_SHIFT
// #HELP_PDF_FILE ""
#DEFAULT_VOLATILE
#ENABLE_STACK_CHECKING
#ENABLE_TRACE
// #ENCODING_ASCII
// #ENCODING_UTF16
// #ENCODING_INHERIT_FROM_PARENT
// #ENCODING_INHERIT_FROM_PROGRAM
#HELP_BEGIN
RS232,9600,8,1,n
#HELP_END

/*******************************************************************************************
DIGITAL, ANALOG and SERIAL INPUTS and OUTPUTS
(Uncomment and declare inputs and outputs as needed)
*******************************************************************************************/
DIGITAL_INPUT Input_Auto,Input_DVD,Input_TV,Input_AUX,Input_BGM,_SKIP_;
DIGITAL_INPUT Mute,_SKIP_;
DIGITAL_INPUT MIC_Up,MIC_Down,_SKIP_,Music_Up,Music_Down,_SKIP_,Effect_Up,Effect_Down,_SKIP_;
DIGITAL_INPUT Preset[MaxNum,MaxNum],_SKIP_;
ANALOG_INPUT _SKIP_,_SKIP_,_SKIP_,_SKIP_;
STRING_INPUT From_Device$[10];
// BUFFER_INPUT

DIGITAL_OUTPUT Input_Auto_Fb,Input_DVD_Fb,Input_TV_Fb,Input_AUX_Fb,Input_BGM_Fb,_SKIP_;
DIGITAL_OUTPUT Mute_Fb,_SKIP_;
DIGITAL_OUTPUT _SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_;
DIGITAL_OUTPUT Preset_Fb[MaxNum,MaxNum],_SKIP_;
ANALOG_OUTPUT MIC_Level,Music_Level,Effect_Level,_SKIP_;
STRING_OUTPUT To_Device$;

/*******************************************************************************************
Parameters
(Uncomment and declare parameters as needed)
*******************************************************************************************/
INTEGER_PARAMETER _SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_;
INTEGER_PARAMETER _SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_;
INTEGER_PARAMETER _SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_,_SKIP_;
INTEGER_PARAMETER _SKIP_,_SKIP_,_SKIP_;
INTEGER_PARAMETER Address;
// SIGNED_INTEGER_PARAMETER
// LONG_INTEGER_PARAMETER
// SIGNED_LONG_INTEGER_PARAMETER
// STRING_PARAMETER

/*******************************************************************************************
Parameter Properties
(Uncomment and declare parameter properties as needed)
*******************************************************************************************/
#BEGIN_PARAMETER_PROPERTIES Address
propValidUnits = unitDecimal|unitHex;// unitString or unitDecimal|unitHex|unitPercent|unitCharacter|unitTime|unitTicks;
propDefaultUnit = unitDecimal;// unitString, unitDecimal, unitHex, unitPercent, unitCharacter, unitTime or unitTicks;
propBounds = 1d,254d;//lower_bound , upper_bound;
propDefaultValue = 1d; // or, propDefaultValue = "";
// propList = // { "value" , "label" } , { "value" , "label" } , ... ;
propShortDescription = "Device ID";
// #BEGIN_PROP_FULL_DESCRIPTION line_1... line_2... line_n #END_PROP_FULL_DESCRIPTION
// #BEGIN_PROP_NOTES line_1... line_2... line_n #END_PROP_NOTES
#END_PARAMETER_PROPERTIES

/*******************************************************************************************
Global Variables
(Uncomment and declare global variables as needed)
Note: Be sure to initialize all declared STRING variables as needed
For example, in Function Main: myString = "";
*******************************************************************************************/
INTEGER cmd,daa,dab;
// LONG_INTEGER
// SIGNED_INTEGER
// SIGNED_LONG_INTEGER
// STRING

/*******************************************************************************************
Functions
(Add any additional functions here)
Note: Functions must be physically placed before the location in
the code that calls them.
*******************************************************************************************/
Function MKString()
{
MakeString(To_Device$,"\x7B\x7D%s%s%s%s\x7D\x7B",chr(Address),chr(cmd),chr(daa),chr(dab));
}

Function SystemStartCheckStatus()
{
cmd = 0x3B;//Input
daa = 0x00;
dab = 0x00;
call MKString();
trace("String: 3b0000");
delay(50);
cmd = 0x38;//Gain
daa = 0x00;//MIC
dab = 0x00;
call MKString();
trace("String: 380000");
delay(50);
cmd = 0x38;//Gain
daa = 0x01;//Music
dab = 0x00;
call MKString();
trace("String: 380100");
delay(50);
cmd = 0x38;//Gain
daa = 0x02;//Effect
dab = 0x00;
call MKString();
trace("String: 380200");
delay(50);
cmd = 0x39;//Mute
daa = 0x00;
dab = 0x00;
call MKString();
trace("String: 390000");
delay(50);
cmd = 0x3A;//Preset
daa = 0x00;
dab = 0x00;
call MKString();
trace("String: 3a0000");
}
/*******************************************************************************************
Event Handlers
(Uncomment and declare additional event handlers as needed)
*******************************************************************************************/
PUSH Input_Auto
{
cmd = 0x34;
daa = 0x00;
dab = 0x00;

call MKString();
}
PUSH Input_DVD
{
cmd = 0x34;
daa = 0x01;
dab = 0x00;
call MKString();
}
PUSH Input_TV
{
cmd = 0x34;
daa = 0x02;
dab = 0x00;
call MKString();
}
PUSH Input_AUX
{
cmd = 0x34;
daa = 0x03;
dab = 0x00;
call MKString();
}
PUSH Input_BGM
{
cmd = 0x34;
daa = 0x04;
dab = 0x00;
call MKString();
}

RELEASE Input_Auto,Input_DVD,Input_TV,Input_AUX,Input_BGM
{
cmd = 0x3B;
daa = 0x00;
dab = 0x00;
call MKString();
}

PUSH MIC_Up
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x00;
dab = 0x00;
call MKString();
delay(50);
}
}

PUSH MIC_Down
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x00;
dab = 0x01;
call MKString();
delay(50);
}
}

PUSH Music_Up
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x01;
dab = 0x00;
call MKString();
delay(50);
}
}

PUSH Music_Down
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x01;
dab = 0x01;
call MKString();
delay(50);
}
}

PUSH Effect_Up
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x02;
dab = 0x00;
call MKString();
delay(50);
}
}

PUSH Effect_Down
{
while(MIC_UP = 1){
cmd = 0x31;
daa = 0x02;
dab = 0x01;
call MKString();
delay(50);
}
}

RELEASE MIC_Up,MIC_Down,Music_Up,Music_Down,Effect_Up,Effect_Down
{
cmd = 0x38;
dab = 0x00;
call MKString();
}

PUSH Mute
{
cmd = 0x32;
if(Mute_Fb = 1){
daa = 0x00;
}Else{
daa = 0x01;
}
dab = 0x00;
call MKString();
}

RELEASE Mute
{
cmd = 0x39;
daa = 0x00;
dab = 0x00;
call MKString();
}

PUSH Preset
{
INTEGER i;
i = GetLastModifiedArrayIndex() - 1;
cmd = 0x33;
if(i < 4){
daa = 0x00;
}ELSE{
daa = 0x01;
}
if(i 0x00){
Mute_Fb = 1;
}ELSE{
Mute_Fb = 0;
}
}
Case(0x3A):{
SetArray(Preset_Fb,0);
Preset_Fb[GetC(From_Device$) + 1] = 1;
}
}

cmd = 0x00;
}
/*******************************************************************************************
Main()
Uncomment and place one-time startup code here
(This code will get called when the system starts up)
*******************************************************************************************/
Function Main()
{
// Address = 0x01;
delay(1000);
call SystemStartCheckStatus();
}