603 lines
17 KiB
C++
603 lines
17 KiB
C++
//////////////////////////////////////////////////////////////////////
|
|
//
|
|
// HAL_Illumination.cpp : interface for the Illumination related functions
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "..\include\resource.h"
|
|
|
|
#include "HAL.h"
|
|
#include "HSI.h"
|
|
|
|
double Intensity[HAL_ILLUMINATION_MAX_LAMPS][HAL_ILLUMINATION_MAX_BULBS];
|
|
bool State[HAL_ILLUMINATION_MAX_LAMPS][HAL_ILLUMINATION_MAX_BULBS];
|
|
//unsigned short LastLevelSent[HAL_ILLUMINATION_MAX_LAMPS][HAL_ILLUMINATION_MAX_BULBS];
|
|
|
|
extern CHAL *g_pHSI;
|
|
extern CHALMicroVuExt g_HSIExt;
|
|
extern CMv_Proto *g_pMv_Proto;
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
bool IsTopLight(int nLamp)
|
|
{
|
|
switch(g_HSIExt.m_ActiveMachineType)
|
|
{
|
|
case HAL_MACHINE_TYPE_EXCEL:
|
|
case HAL_MACHINE_TYPE_VECTRA:
|
|
default:
|
|
if(nLamp == 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
bool IsBottomLight(int nLamp)
|
|
{
|
|
UNREFERENCED_PARAMETER(nLamp);
|
|
switch(g_HSIExt.m_ActiveMachineType)
|
|
{
|
|
case HAL_MACHINE_TYPE_VECTRA:
|
|
case HAL_MACHINE_TYPE_EXCEL:
|
|
default:
|
|
if(nLamp == 1)
|
|
return true;
|
|
else
|
|
return false;
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
bool IsRingLight(int nLamp)
|
|
{
|
|
switch(g_HSIExt.m_ActiveMachineType)
|
|
{
|
|
case HAL_MACHINE_TYPE_VECTRA:
|
|
case HAL_MACHINE_TYPE_EXCEL:
|
|
default:
|
|
if(nLamp == 2)
|
|
return true;
|
|
else
|
|
return false;
|
|
break;
|
|
}
|
|
}
|
|
// Map a lamp from the PCDMIS ring light to the MicroVu ring light
|
|
// MV start with the inner ring. The first or zero lamp is at 12 oclock and goes CCW
|
|
// PCD starts with the outer ring. The first or zero lamp is at 12 oclock and goes CW
|
|
//////////////////////////////////////////////////////////////////////
|
|
int PCDRingBulbToMicroVu_8x5(int Lamp)
|
|
{
|
|
switch(Lamp)
|
|
{
|
|
case 0:
|
|
return 32;
|
|
case 1:
|
|
return 39;
|
|
case 2:
|
|
return 38;
|
|
case 3:
|
|
return 37;
|
|
case 4:
|
|
return 36;
|
|
case 5:
|
|
return 35;
|
|
case 6:
|
|
return 34;
|
|
case 7:
|
|
return 33;
|
|
|
|
case 8:
|
|
return 24;
|
|
case 9:
|
|
return 31;
|
|
case 10:
|
|
return 30;
|
|
case 11:
|
|
return 29;
|
|
case 12:
|
|
return 28;
|
|
case 13:
|
|
return 27;
|
|
case 14:
|
|
return 26;
|
|
case 15:
|
|
return 25;
|
|
|
|
case 16:
|
|
return 16;
|
|
case 17:
|
|
return 23;
|
|
case 18:
|
|
return 22;
|
|
case 19:
|
|
return 21;
|
|
case 20:
|
|
return 20;
|
|
case 21:
|
|
return 19;
|
|
case 22:
|
|
return 18;
|
|
case 23:
|
|
return 17;
|
|
|
|
case 24:
|
|
return 8;
|
|
case 25:
|
|
return 15;
|
|
case 26:
|
|
return 14;
|
|
case 27:
|
|
return 13;
|
|
case 28:
|
|
return 12;
|
|
case 29:
|
|
return 11;
|
|
case 30:
|
|
return 10;
|
|
case 31:
|
|
return 9;
|
|
|
|
case 32:
|
|
return 0;
|
|
case 33:
|
|
return 7;
|
|
case 34:
|
|
return 6;
|
|
case 35:
|
|
return 5;
|
|
case 36:
|
|
return 4;
|
|
case 37:
|
|
return 3;
|
|
case 38:
|
|
return 2;
|
|
case 39:
|
|
return 1;
|
|
}
|
|
ASSERT(0);
|
|
return 0;
|
|
}
|
|
|
|
// Map a lamp from the PCDMIS ring light to the MicroVu ring light
|
|
// MV start with the inner ring. The first or zero lamp is at 12 oclock and goes CCW
|
|
// PCD starts with the outer ring. The first or zero lamp is at 12 oclock and goes CW
|
|
//////////////////////////////////////////////////////////////////////
|
|
int PCDRingBulbToMicroVu_8x2(int Lamp)
|
|
{
|
|
switch(Lamp)
|
|
{
|
|
case 0:
|
|
return 8;
|
|
case 1:
|
|
return 9;
|
|
case 2:
|
|
return 10;
|
|
case 3:
|
|
return 11;
|
|
case 4:
|
|
return 12;
|
|
case 5:
|
|
return 13;
|
|
case 6:
|
|
return 14;
|
|
case 7:
|
|
return 15;
|
|
case 8:
|
|
return 0;
|
|
case 9:
|
|
return 1;
|
|
case 10:
|
|
return 2;
|
|
case 11:
|
|
return 3;
|
|
case 12:
|
|
return 4;
|
|
case 13:
|
|
return 5;
|
|
case 14:
|
|
return 6;
|
|
case 15:
|
|
return 7;
|
|
}
|
|
ASSERT(0);
|
|
return 0;
|
|
}
|
|
|
|
// Map a lamp from the PCDMIS ring light to the MicroVu ring light
|
|
// MV start with the inner ring. The first or zero lamp is at 12 oclock and goes CCW
|
|
// PCD starts with the outer ring. The first or zero lamp is at 12 oclock and goes CW
|
|
//////////////////////////////////////////////////////////////////////
|
|
int PCDRingBulbToMicroVu(int Lamp)
|
|
{
|
|
if ((g_HSIExt.m_NumRings == 2) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
PCDRingBulbToMicroVu_8x2(Lamp);
|
|
}
|
|
else
|
|
if ((g_HSIExt.m_NumRings == 3) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
PCDRingBulbToMicroVu_8x5(Lamp);
|
|
}
|
|
else
|
|
{
|
|
PCDRingBulbToMicroVu_8x5(Lamp);
|
|
};
|
|
return 0;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_IsSupported(UINT &Type)
|
|
{
|
|
Type = HAL_ILLUMINATION_SUPPORTS_DCC_CONTROL;
|
|
|
|
HAL_SendDebug(_T("HAL_Illumination_IsSupported %X\n"), Type);
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_Startup( )
|
|
{
|
|
memset(Intensity, 0, sizeof(Intensity));
|
|
memset(State, 1, sizeof(State));
|
|
|
|
switch(g_HSIExt.m_ActiveMachineType)
|
|
{
|
|
case HAL_MACHINE_TYPE_EXCEL:
|
|
case HAL_MACHINE_TYPE_VECTRA:
|
|
g_pMv_Proto->mv_light_set_light_off();
|
|
break;
|
|
}
|
|
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_GetLampCount( int &nLamps )
|
|
{
|
|
UINT NumLamps = 0;
|
|
|
|
switch(g_HSIExt.m_ActiveMachineType)
|
|
{
|
|
case HAL_MACHINE_TYPE_EXCEL:
|
|
case HAL_MACHINE_TYPE_VECTRA:
|
|
NumLamps = 4;
|
|
break;
|
|
}
|
|
|
|
ASSERT(NumLamps <= HAL_ILLUMINATION_MAX_LAMPS);
|
|
|
|
nLamps = NumLamps;
|
|
|
|
HAL_SendDebug(_T("HAL_Illumination_GetLampCount %d\n"), NumLamps);
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_GetLampInfo( int nLamp, TCHAR LampName[HAL_MaxLampNameLength+1], TCHAR LampDescription[HAL_MaxLampDescriptionLength+1],
|
|
enum HAL_ILLUMINATION_LAMP_LOCATION_TYPE &LocationType, int &LocationAngle,
|
|
enum HAL_ILLUMINATION_BULB_TYPE &BulbType,
|
|
enum HAL_ILLUMINATION_BULB_CONTROL_TYPE &BulbControlType,
|
|
enum HAL_ILLUMINATION_INTENSITY_CONTROL_TYPE &IntensityControlType,
|
|
int &NumColors, COLORREF *Colors,
|
|
int &NumRings, int *NumSectors,
|
|
double &MinAngle, double &MaxAngle,
|
|
bool &bCanBeCalibrated)
|
|
{
|
|
if(IsTopLight(nLamp))
|
|
{
|
|
LocationType = HAL_ILLUMINATION_LAMP_LOCATION_TOP_ON_AXIS;
|
|
BulbType = HAL_ILLUMINATION_BULB_ROUND;
|
|
BulbControlType = HAL_ILLUMINATION_BULB_CONTROL_BY_LAMP;
|
|
IntensityControlType = HAL_ILLUMINATION_INTENSITY_CONTROL_BY_LAMP;
|
|
CString LampNameStr;
|
|
LampNameStr.LoadString(IDS_ILLUMINATION_TOP);
|
|
wcsncpy_s(LampName, HAL_MaxLampNameLength+1, LampNameStr, HAL_MaxLampNameLength);
|
|
wcsncpy_s(LampDescription, HAL_MaxLampDescriptionLength+1, _T("MicroVu Coaxial Light"), HAL_MaxLampDescriptionLength);
|
|
NumColors = 1;
|
|
Colors[0] = RGB(255, 255, 255);
|
|
NumRings = 0;
|
|
NumSectors = 0;
|
|
LocationAngle = 0;
|
|
MinAngle = 0.0;
|
|
MaxAngle = 0.0;
|
|
bCanBeCalibrated = true;
|
|
}
|
|
|
|
if(IsBottomLight(nLamp))
|
|
{
|
|
LocationType = HAL_ILLUMINATION_LAMP_LOCATION_BOTTOM;
|
|
BulbType = HAL_ILLUMINATION_BULB_ROUND;
|
|
BulbControlType = HAL_ILLUMINATION_BULB_CONTROL_BY_LAMP;
|
|
IntensityControlType = HAL_ILLUMINATION_INTENSITY_CONTROL_BY_LAMP;
|
|
CString LampNameStr;
|
|
LampNameStr.LoadString(IDS_ILLUMINATION_BTM);
|
|
wcsncpy_s(LampName,HAL_MaxLampNameLength+1,LampNameStr,HAL_MaxLampNameLength);
|
|
wcsncpy_s(LampDescription,HAL_MaxLampDescriptionLength+1,_T("MicroVu Backlight (Green)"),HAL_MaxLampDescriptionLength);
|
|
NumColors = 1;
|
|
Colors[0] = RGB(255, 255, 255);
|
|
NumRings = 0;
|
|
NumSectors = 0;
|
|
LocationAngle = 0;
|
|
MinAngle = 0.0;
|
|
MaxAngle = 0.0;
|
|
bCanBeCalibrated = true;
|
|
}
|
|
|
|
if(IsRingLight(nLamp))
|
|
{
|
|
LocationType = HAL_ILLUMINATION_LAMP_LOCATION_TOP_ANGLED;
|
|
BulbType = HAL_ILLUMINATION_BULB_RING;
|
|
BulbControlType = HAL_ILLUMINATION_BULB_CONTROL_BY_BULB;
|
|
IntensityControlType = HAL_ILLUMINATION_INTENSITY_CONTROL_BY_BULB;
|
|
|
|
CString LampNameStr;
|
|
LampNameStr.LoadString(IDS_ILLUMINATION_RNG);
|
|
wcsncpy_s(LampName, HAL_MaxLampNameLength+1, LampNameStr, HAL_MaxLampNameLength);
|
|
wcsncpy_s(LampDescription, HAL_MaxLampDescriptionLength+1, _T("MicroVu Ringlight"), HAL_MaxLampDescriptionLength);
|
|
NumColors = 1;
|
|
Colors[0] = RGB(255, 255, 255);
|
|
|
|
NumRings = g_HSIExt.m_NumRings;
|
|
for(int i = 0 ; i < NumRings ; i++)
|
|
NumSectors[i] = g_HSIExt.m_NumSegs;
|
|
|
|
LocationAngle = 0;
|
|
|
|
MinAngle = 0.0;
|
|
MaxAngle = 0.0;
|
|
|
|
bCanBeCalibrated = true;
|
|
}
|
|
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
int GetLampNumberFromLocation(const enum HAL_ILLUMINATION_LAMP_LOCATION_TYPE SearchLocationType)
|
|
{
|
|
for(int nLamp=0;nLamp<HAL_ILLUMINATION_MAX_LAMPS;nLamp++)
|
|
{
|
|
TCHAR LampName[HAL_MaxLampNameLength+1], LampDescription[HAL_MaxLampDescriptionLength+1];
|
|
enum HAL_ILLUMINATION_LAMP_LOCATION_TYPE LocationType=HAL_ILLUMINATION_LAMP_LOCATION_TOP_ON_AXIS;
|
|
enum HAL_ILLUMINATION_BULB_TYPE BulbType=HAL_ILLUMINATION_BULB_ROUND;
|
|
enum HAL_ILLUMINATION_BULB_CONTROL_TYPE BulbControlType=HAL_ILLUMINATION_BULB_CONTROL_BY_LAMP;
|
|
enum HAL_ILLUMINATION_INTENSITY_CONTROL_TYPE IntensityControlType=HAL_ILLUMINATION_INTENSITY_CONTROL_BY_LAMP;
|
|
int NumColors=1, NumRings=0,NumSectors[HAL_ILLUMINATION_MAX_SECTORS], LocationAngle=0;
|
|
COLORREF Colors[HAL_ILLUMINATION_MAX_BULB_COLORS];
|
|
Colors[0]=RGB(255,255,255);
|
|
double MinAngle=0.0,MaxAngle=0.0;
|
|
bool bCanBeCalibrated=true;
|
|
|
|
HAL_STATUS Status=HAL_Illumination_GetLampInfo(nLamp,LampName,LampDescription,LocationType,LocationAngle,BulbType,
|
|
BulbControlType,IntensityControlType,NumColors,Colors,NumRings,
|
|
NumSectors,MinAngle,MaxAngle,bCanBeCalibrated);
|
|
|
|
if((Status==HAL_STATUS_NORMAL) && (LocationType==SearchLocationType))
|
|
return nLamp;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_GetLampState_2x8( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int & Color, double & Angle )
|
|
{
|
|
if(IsTopLight(nLamp))
|
|
{
|
|
bBulbStates[0] = g_HSIExt.m_LampOutputState_2x8[nLamp][0];
|
|
Intensities[0] = g_HSIExt.m_LampOutputLevel_2x8[nLamp][0];
|
|
}
|
|
|
|
if(IsBottomLight(nLamp))
|
|
{
|
|
bBulbStates[0] = g_HSIExt.m_LampOutputState_2x8[nLamp][0];
|
|
Intensities[0] = g_HSIExt.m_LampOutputLevel_2x8[nLamp][0];
|
|
}
|
|
|
|
if(IsRingLight(nLamp))
|
|
{
|
|
for(int Bulb = 0 ; Bulb < TWO_RINGS * EIGHT_SEGS; Bulb++)
|
|
{
|
|
bBulbStates[Bulb] = g_HSIExt.m_LampOutputState_2x8[nLamp][Bulb];
|
|
Intensities[Bulb] = g_HSIExt.m_LampOutputLevel_2x8[nLamp][Bulb];
|
|
}
|
|
}
|
|
|
|
Color=0;
|
|
Angle=0.0;
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_GetLampState_5x8( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int & Color, double & Angle )
|
|
{
|
|
if(IsTopLight(nLamp))
|
|
{
|
|
bBulbStates[0] = g_HSIExt.m_LampOutputState_5x8[nLamp][0];
|
|
Intensities[0] = g_HSIExt.m_LampOutputLevel_5x8[nLamp][0];
|
|
}
|
|
|
|
if(IsBottomLight(nLamp))
|
|
{
|
|
bBulbStates[0] = g_HSIExt.m_LampOutputState_5x8[nLamp][0];
|
|
Intensities[0] = g_HSIExt.m_LampOutputLevel_5x8[nLamp][0];
|
|
}
|
|
|
|
if(IsRingLight(nLamp))
|
|
{
|
|
for(int Bulb = 0 ; Bulb < TWO_RINGS * EIGHT_SEGS; Bulb++)
|
|
{
|
|
bBulbStates[Bulb] = g_HSIExt.m_LampOutputState_5x8[nLamp][Bulb];
|
|
Intensities[Bulb] = g_HSIExt.m_LampOutputLevel_5x8[nLamp][Bulb];
|
|
}
|
|
}
|
|
|
|
Color=0;
|
|
Angle=0.0;
|
|
|
|
return HAL_STATUS_NORMAL;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_GetLampState( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int & Color, double & Angle )
|
|
{
|
|
if ((g_HSIExt.m_NumRings == 2) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
HAL_Illumination_GetLampState_2x8(nLamp, bBulbStates, Intensities, Color, Angle);
|
|
}
|
|
else
|
|
if ((g_HSIExt.m_NumRings == 5) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
HAL_Illumination_GetLampState_5x8(nLamp, bBulbStates, Intensities, Color, Angle);
|
|
}
|
|
else
|
|
{
|
|
HAL_Illumination_GetLampState_5x8(nLamp, bBulbStates, Intensities, Color, Angle);
|
|
};
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_SetLampState_2x8( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int /*Color*/, double /*Angle*/, bool bWait )
|
|
{
|
|
static unsigned short MaxLevelChange = 0;
|
|
|
|
if(IsTopLight(nLamp))
|
|
{
|
|
g_HSIExt.m_LampOutputState_2x8[nLamp][0] = bBulbStates[0];
|
|
g_HSIExt.m_LampOutputLevel_2x8[nLamp][0] = Intensities[0];
|
|
}
|
|
|
|
if(IsBottomLight(nLamp))
|
|
{
|
|
g_HSIExt.m_LampOutputState_2x8[nLamp][0] = bBulbStates[0];
|
|
g_HSIExt.m_LampOutputLevel_2x8[nLamp][0] = Intensities[0];
|
|
}
|
|
|
|
if(IsRingLight(nLamp))
|
|
{
|
|
for(int Bulb = 0 ; Bulb < TWO_RINGS*EIGHT_SEGS ; Bulb++)
|
|
{
|
|
g_HSIExt.m_LampOutputState_2x8[nLamp][Bulb] = bBulbStates[Bulb];
|
|
g_HSIExt.m_LampOutputLevel_2x8[nLamp][Bulb] = Intensities[Bulb];
|
|
g_HSIExt.m_LampOutputLevelForMVRing_2x8[PCDRingBulbToMicroVu(Bulb)] = bBulbStates[Bulb]?Intensities[Bulb]:0.0;
|
|
}
|
|
}
|
|
g_pMv_Proto->mv_set_ringlight_data(TWO_RINGS * EIGHT_SEGS, g_HSIExt.m_LampOutputLevelForMVRing_2x8);
|
|
|
|
double dBottomIntensity = (g_HSIExt.m_LampOutputState_2x8[1][0])?g_HSIExt.m_LampOutputLevel_2x8[1][0]:0.0;
|
|
double dTopIntensity = (g_HSIExt.m_LampOutputState_2x8[0][0])?g_HSIExt.m_LampOutputLevel_2x8[0][0]:0.0;
|
|
g_pMv_Proto->mv_light_set_lamp_state(dBottomIntensity,dTopIntensity);
|
|
g_pMv_Proto->mv_light_set_light();
|
|
|
|
#pragma message("We need to determine a good value for the wait")
|
|
Sleep(60);
|
|
|
|
// Only wait if we've been asked to wait, and one of the lamps has changed in this set of changes,
|
|
// and this is the last lamp
|
|
if(bWait)
|
|
{
|
|
#pragma message("Testing needs to be done to find a good lighting delay, if any")
|
|
int Time=(int)(g_HSIExt.m_IllumSettleTime * 1000.0);
|
|
CString TimeStr;
|
|
TimeStr.Format(_T("HAL_Illumination_SetLampState MaxLevelChange %d so sleeping for %fs\n"),MaxLevelChange,(double)Time/1000.0);
|
|
HAL_SendDebug(TimeStr);
|
|
Sleep(Time); // A totally off to totally on switch would give max of 500ms
|
|
MaxLevelChange=0;
|
|
}
|
|
|
|
return HAL_STATUS_NORMAL;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_SetLampState_5x8( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int /*Color*/, double /*Angle*/, bool bWait )
|
|
{
|
|
static unsigned short MaxLevelChange = 0;
|
|
|
|
if(IsTopLight(nLamp))
|
|
{
|
|
g_HSIExt.m_LampOutputState_5x8[nLamp][0] = bBulbStates[0];
|
|
g_HSIExt.m_LampOutputLevel_5x8[nLamp][0] = Intensities[0];
|
|
}
|
|
|
|
if(IsBottomLight(nLamp))
|
|
{
|
|
g_HSIExt.m_LampOutputState_5x8[nLamp][0] = bBulbStates[0];
|
|
g_HSIExt.m_LampOutputLevel_5x8[nLamp][0] = Intensities[0];
|
|
}
|
|
|
|
if(IsRingLight(nLamp))
|
|
{
|
|
for(int Bulb = 0 ; Bulb < TWO_RINGS*EIGHT_SEGS ; Bulb++)
|
|
{
|
|
g_HSIExt.m_LampOutputState_5x8[nLamp][Bulb] = bBulbStates[Bulb];
|
|
g_HSIExt.m_LampOutputLevel_5x8[nLamp][Bulb] = Intensities[Bulb];
|
|
g_HSIExt.m_LampOutputLevelForMVRing_5x8[PCDRingBulbToMicroVu(Bulb)] = bBulbStates[Bulb]?Intensities[Bulb]:0.0;
|
|
}
|
|
}
|
|
g_pMv_Proto->mv_set_ringlight_data(FIVE_RINGS * EIGHT_SEGS, g_HSIExt.m_LampOutputLevelForMVRing_5x8);
|
|
|
|
double dBottomIntensity = (g_HSIExt.m_LampOutputState_5x8[1][0])?g_HSIExt.m_LampOutputLevel_5x8[1][0]:0.0;
|
|
double dTopIntensity = (g_HSIExt.m_LampOutputState_5x8[0][0])?g_HSIExt.m_LampOutputLevel_5x8[0][0]:0.0;
|
|
g_pMv_Proto->mv_light_set_lamp_state(dBottomIntensity,dTopIntensity);
|
|
g_pMv_Proto->mv_light_set_light();
|
|
|
|
#pragma message("We need to determine a good value for the wait")
|
|
Sleep(60);
|
|
|
|
// Only wait if we've been asked to wait, and one of the lamps has changed in this set of changes,
|
|
// and this is the last lamp
|
|
if(bWait)
|
|
{
|
|
#pragma message("Testing needs to be done to find a good lighting delay, if any")
|
|
int Time=(int)(g_HSIExt.m_IllumSettleTime * 1000.0);
|
|
CString TimeStr;
|
|
TimeStr.Format(_T("HAL_Illumination_SetLampState MaxLevelChange %d so sleeping for %fs\n"),MaxLevelChange,(double)Time/1000.0);
|
|
HAL_SendDebug(TimeStr);
|
|
Sleep(Time); // A totally off to totally on switch would give max of 500ms
|
|
MaxLevelChange=0;
|
|
}
|
|
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
HAL_STATUS HAL_Illumination_SetLampState( int nLamp, bool *bBulbStates, double *Intensities,
|
|
int /*Color*/, double /*Angle*/, bool bWait )
|
|
{
|
|
if ((g_HSIExt.m_NumRings == 2) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
HAL_Illumination_SetLampState_2x8(nLamp, bBulbStates, Intensities, 0, 0.0, bWait);
|
|
}
|
|
else
|
|
if ((g_HSIExt.m_NumRings == 5) && (g_HSIExt.m_NumSegs == 8))
|
|
{
|
|
HAL_Illumination_SetLampState_5x8(nLamp, bBulbStates, Intensities, 0, 0.0, bWait);
|
|
}
|
|
else
|
|
{
|
|
HAL_Illumination_SetLampState_5x8(nLamp, bBulbStates, Intensities, 0, 0.0, bWait);
|
|
};
|
|
return HAL_STATUS_NORMAL;
|
|
}
|
|
|
|
HAL_STATUS HAL_Illumination_Shutdown( )
|
|
{
|
|
g_pMv_Proto->mv_light_set_light_off();
|
|
return HAL_STATUS_NORMAL;
|
|
}
|