
unit Light
{
	public const uint16 ID = 0;

	//[i] linkinterface_analog output;
	link unit output {}
	
	//[i] var_uint8 OS_time;
	uint8 OS_time;
	
	//[i] linkconst_int32_0 MinValue;
	public const int32 MinValue = 0;
	//[i] linkconst_int32_100 MaxValue;
	public const int32 MaxValue = 0;
	
	//[i] linkvar_int32_1.0_Γλ Time;
	public myType int32 Time;
	memory myType
	{
		//target = myType_driver;
	}
	
	public uint8 t_Time;
	uint32 t_Time32;
	
	public void set_uint32( uint32 v )
	{
		t_Time32 = v;
		t_Time = (uint8)(uint16)( v / (uint)(MaxValue - MinValue) / 2 );
	}
	public uint32 get_uint32()
	{
		return t_Time32;
	}
	
	
	int32 value;
	int8 next;
	uint8 tick;
	
	bool runing;
	
	//[i] interface_digital digital0;
	unit digital0
	{
		public link void open() {}
		public link void close() {}
	}
	digital0.open = start;
	digital0.close = stop;
	
	//---------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		OS_time = 1;
		
		value = MinValue;
		next = 1;
		tick = 0;
		
		runing = false;
	}
	//---------------------------------------------------
	//[i] function_void OS_run;
	public void OS_run()
	{
		if( !runing ) {
			return;
		}
		tick + 1;
		if( tick < t_Time ) {
			return;
		}
		tick = 0;
		
		value + next;
		if( value == MaxValue || value == MinValue ) {
			-next;
		}
		output.SetValue( value );
	}
	//---------------------------------------------------
	//[i] function_void start;
	public void start()
	{
		runing = true;
	}
	//---------------------------------------------------
	//[i] function_void stop;
	public void stop()
	{
		runing = false;
		output.Stop();
	}
}



