I use below code for #1 screenshot.
int _objfnd = ObjectFind( name );
if ( _objfnd == -1 )
{
ObjectCreate ( _vlineName, OBJ_VLINE, 0, Time[i], 0 );
...
}
and I use below code for #2 screenshot.
int _objfnd = ObjectFind( name );
if ( _objfnd == -1 )
{
datetime _dayTime = Time[i] ;
int _dayNext = PeriodSeconds( _Session_Breaks_Day_Prd ) ;
_dayTime = _dayTime - ( _dayTime % _dayNext ) + _dayNext ;
ObjectCreate ( _vlineName, OBJ_VLINE, 0, _dayTime, 0 ) ;
}
If you figure out my concern,please give me good advice, much appreciate.
A: the code has not handled Daylight Saving Time Shift 2016, Nov-06
Related
Is that possible to add a close_above_open condition too in the pattern of iHigh() && iClose() && iLow()?
I.e. I would like to add the close_above_open in the below code. Can you help me to know the method?
const int timePeriodD1=PERIOD_D1;
if(iHigh(symbol,timePeriodD1,1)>iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) >iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)>iLow(symbol,timePeriodD1,2)){
//ObjectSetText(d1label,"UP",11, "Verdana", Aqua);
d1result="UP";
}else if(iHigh(symbol,timePeriodD1,1)<iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) < iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)< iLow(symbol,timePeriodD1,2)){
//ObjectSetText(d1label,"DOWN",11, "Verdana", Yellow);
d1result="DOWN";
}else{
//ObjectSetText(d1label,"MIXED",11, "Verdana", White);
d1result="MIXED";
}
Simply asking is there any way to write as below:
if(iHigh(symbol,timePeriodD1,1)>iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) >iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)>iLow(symbol,timePeriodD1,2) &&
CloseAboveOpen(symbol,timePeriodD1,1)>CloseAboveOpen(symbol,timePeriodD1,2)
Q1 : Is that possible to add a close_above_open condition too in the pattern of iHigh() && iClose() && iLow()?
Yes, it is:
...
if ( iHigh( symbol, timePeriodD1, 1 ) > iHigh( symbol, timePeriodD1, 2 )
&& iClose( symbol, timePeriodD1, 1 ) > iClose( symbol, timePeriodD1, 2 )
&& iLow( symbol, timePeriodD1, 1 ) > iLow( symbol, timePeriodD1, 2 )
&& CloseAboveOpen( symbol, timePeriodD1, 1 ) > CloseAboveOpen( symbol, timePeriodD1, 2 )
){ ... }
...
Q2 : Simply asking is there any way to write it as below...?
Yes, there is.
May try to customize this template to match your further needs:
int CloseAboveOpen( string aSymbolNAME, /// [DOC-me] Ret-s {+|-}n-pts above Open
int aTimeFRAME,
int nOffsetBARs ) {
return( (int)( ( iClose( aSymbolNAME, aTimeFRAME, nOffsetBARs )
- iOpen( aSymbolNAME, aTimeFRAME, nOffsetBARs )
)
* MathPow( 10, (int)MarketInfo( aSymbolNAME, MODE_DIGITS ) )
)
);
}
sample code
ITypeLib* pp;
TLIBATTR* a;
//C:\Program Files\Microsoft Office\Office15\MSPPT.OLB
LoadTypeLibEx(_T("C:\\Program Files\\Microsoft Office\\Office15\\MSPPT.OLB"), (REGKIND)(REGKIND_NONE| LOAD_TLB_AS_64BIT), &pp);
pp->GetLibAttr(&a);
Check that the value of a->syskind is always equal to 1(means SYS_WIN32).
enum tagSYSKIND
{
SYS_WIN16 = 0,
SYS_WIN32 = ( SYS_WIN16 + 1 ) ,
SYS_MAC = ( SYS_WIN32 + 1 ) ,
SYS_WIN64 = ( SYS_MAC + 1 )
} SYSKIND;
Whether the calling method is wrong, why the flag bit LOAD_TLB_AS_64BIT does not take effect.
The expected value is SYS_WIN64
I'm trying to interface to a Huawei device (MA5608T) via Python through SNMP.I learned that there is a correspondence between the index value and the port.
But I still don't understand how it translates
for example:
4194445056.0(index) = 0/17/7(port)
does anyone know what are the steps to do?
try this way:
4194304000 + (slot * (256 * 32)) + pon * 256) + '.' + onu_id
This Javascript code is taken from production. The binary operations will give you a clue on how to extract the data from the packet.
function convert_snmp_packet( packet ){
let regex = /[^\.]*/g;
let found = packet.match( regex );
if( found.length < 2 ) {
throw new Error( "wrong packet ? " + packet );
}
let left_part = parseInt( found[0] );
// found[1] is just the dot
let ont_index = parseInt( found[ 2 ] );
let slot_num;
let port_num;
slot_num = ( left_part & ( 15 << 13 ) ) >> 13;
port_num = ( left_part & ( 15 << 8 ) ) >> 8;
let json = {
slot_num: slot_num,
port_num: port_num,
ont_index: ont_index
};
return json;
}
test code:
class packet_Test extends Test {
test_packet( ){
// packet must be a String for this to work
let p = "4194445056.0";
let actual = convert_snmp_packet( p );
let expected = { slot_num: 1, port_num: 7, ont_index: 0 };
this.assertEquals( expected, actual );
this.done()
}
}
Sorry for the necromancy. Ran into this while looking for information about SNMP over a Huawei olt.
Is there any way to align the text (justify/left/right alignment)shown below token field in login page of custom credential provider
If you have a look at credentialprovider.h
typedef /* [v1_enum] */
enum _CREDENTIAL_PROVIDER_FIELD_STATE
{
CPFS_HIDDEN = 0,
CPFS_DISPLAY_IN_SELECTED_TILE = ( CPFS_HIDDEN + 1 ) ,
CPFS_DISPLAY_IN_DESELECTED_TILE = ( CPFS_DISPLAY_IN_SELECTED_TILE + 1 ) ,
CPFS_DISPLAY_IN_BOTH = ( CPFS_DISPLAY_IN_DESELECTED_TILE + 1 )
} CREDENTIAL_PROVIDER_FIELD_STATE;
typedef /* [v1_enum] */
enum _CREDENTIAL_PROVIDER_FIELD_INTERACTIVE_STATE
{
CPFIS_NONE = 0,
CPFIS_READONLY = ( CPFIS_NONE + 1 ) ,
CPFIS_DISABLED = ( CPFIS_READONLY + 1 ) ,
CPFIS_FOCUSED = ( CPFIS_DISABLED + 1 )
} CREDENTIAL_PROVIDER_FIELD_INTERACTIVE_STATE;
There is no provision for alignment for a field in CREDENTIAL_PROVIDER_FIELD_STATE. There is no API/constant to declare the aligment of a specific field. The only alignment Credential Provider does is "Center alignment".
I'm building a simple AudioUnit app which should use an AUGraph to connect a generator (which generates, say, a sine wave) to a format converter (because that seems like what I need) to an output device.
Code snippets:
{
AudioComponentDescription desc ;
desc.componentType = kAudioUnitType_Generator ;
desc.componentSubType = kAudioUnitSubType_ScheduledSoundPlayer ;
desc.componentFlags = 0 ;
desc.componentFlagsMask = 0 ;
desc.componentManufacturer = kAudioUnitManufacturer_Apple ;
status = AUGraphAddNode ( mGraph , &desc , &mGeneratorNode ) ;
checkOSStatus ( "creating generator node" , status ) ;
}
I do similarly for mConverterNode with kAudioUnitType_FormatConverter/kAudioUnitSubType_AUConverter and for mOutputNode with kAudioUnitType_Output/kAudioUnitSubType_DefaultOutput.
I then open the graph:
AUGraphOpen ( mGraph ) ; // error checking code omitted from example
I then get references to them:
AUGraphNodeInfo ( mGraph , mGeneratorNode , 0,&mGeneratorRef ) ; // error checking code omitted from example
I then set the format:
{
AudioStreamBasicDescription format ;
format.mSampleRate = mSamplingRate ;
format.mFormatID = kAudioFormatLinearPCM ;
format.mFormatFlags = kAudioFormatFlagIsSignedInteger ;
format.mFramesPerPacket = 1 ;
format.mChannelsPerFrame = 1 ; // mono
format.mBitsPerChannel = 16 ;
format.mBytesPerFrame = format.mBitsPerChannel*format.mChannelsPerFrame/8 ;
format.mBytesPerPacket = format.mBytesPerFrame*format.mFramesPerPacket ;
status = AudioUnitSetProperty ( mGeneratorRef , kAudioUnitProperty_StreamFormat , kAudioUnitScope_Output , kOutputBus , &format,sizeof(format) ) ;
checkOSStatus ( "setting output format" , status ) ;
}
(Note: kOutputBus is an enum to 0; it's an anachronism from a previous example I found. Also, mSamplingRate is a size_t whose value is 48000)
And set the render callback:
{
AURenderCallbackStruct cb ;
cb.inputProc = &_callbackProxy ;
cb.inputProcRefCon = static_cast<void*> ( this ) ;
status = AudioUnitSetProperty ( mGeneratorRef , kAudioUnitProperty_SetRenderCallback , kAudioUnitScope_Output , 0 , &cb,sizeof(cb) ) ;
checkOSStatus ( "setting the generator callback" , status ) ;
}
However, for both the stream format and the render callback I get kAudio_ParamError back as the resultant status.
No matter what I do (mono/stereo, when I place that command, etc), I cannot make it work.
Note: I later do this:
AUGraphConnectNodeInput ( mGraph , mGeneratorNode,0 , mConverterNode,0 ) ;
AUGraphConnectNodeInput ( mGraph , mConverterNode,0 , mOutputNode,0 ) ;
AUGraphInitialize ( mGraph ) ;
AUGraphStart ( mGraph ) ;
// again, error-checking code omitted from example
And it works........ But I can't set those properties and therefore can't generate audio.
What am I missing?
(To people with 1500+ reputation: please make an "osx-sierra" tag; I'm a bit shy of that mark)
From an obscure comment at the end of this:
https://discussions.apple.com/thread/1989797?tstart=0
I ran AUGraphOpen at the very beginning before creating things (why?) and it worked.
But then I was getting invalid format errors, so I set the format on the input of the converter instead of the output of the generator.
But then it wasn't calling the render callback, so I removed the generator altogether and put the render callback on the input of the converter.
At this point, it worked and is generating my sound.
I hope this helps somebody else in the future with this so-horribly-documented API.