
//2015.5.27
//开始设计波形发送器

unit Protocol
{
	public const uint16 ID = 0;

	//[i] linkinterface_writer writer0;
	link unit writer0 {}
	
	bool NeedSend;
	
	//---------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		NeedSend = false;
	}
	//---------------------------------------------------
	//[i] function_void OS_thread;
	public void OS_thread()
	{
		if( NeedSend ) {
			NeedSend = false;
			writer0.SetData( (int)0xAB );
		}
	}
	//---------------------------------------------------
	//[i] function_void set_data int32 int32;
	void set_data( int32 c, int32 i )
	{
		uint32 d = (uint)i;
		if( c < 1 ) {
			return;
		}
		writer0.SetData( (int)0xAA );
		writer0.SetData( (int8)(int16)(c - 1) );
		writer0.SetData( (int)d.0(uint8) );
		writer0.SetData( (int)d.8(uint8) );
		writer0.SetData( (int)d.16(uint8) );
		writer0.SetData( (int)d.24(uint8) );
		NeedSend = true;
	}
}



