public static long oHpiDomainAdd( SaHpiTextBufferT Host, int Port, SaHpiEntityPathT EntityRoot, out long DomainId ) { DomainId = 0; String s = HpiUtil.FromSaHpiTextBufferT(Host); if (s == null) { return(HpiConst.SA_ERR_HPI_INVALID_PARAMS); } HpiDomain d = HpiCore.CreateDomain(s, Port, EntityRoot); if (d == null) { return(HpiConst.SA_ERR_HPI_INTERNAL_ERROR); } DomainId = d.GetLocalDid(); return(HpiConst.SA_OK); }
/********************************************************** * Text Buffer Helpers *********************************************************/ public static string FromSaHpiTextBufferT(SaHpiTextBufferT tb) { // NB: Only BCD+/ASCII6/ASCII(Eng)/ are now supported. // TODO implement further bool ok = false; ok = ok || (tb.DataType == HpiConst.SAHPI_TL_TYPE_BCDPLUS); ok = ok || (tb.DataType == HpiConst.SAHPI_TL_TYPE_ASCII6); bool eng = (tb.Language == HpiConst.SAHPI_LANG_ENGLISH); ok = ok || ((tb.DataType == HpiConst.SAHPI_TL_TYPE_TEXT) && eng); string s = null; if (ok) { char[] data = new char[tb.DataLength]; Array.Copy(tb.Data, data, tb.DataLength); s = new string( data, 0, unchecked ((int)tb.DataLength)); } else { throw new FormatException(); } return(s); }
/********************************************************** * Check Functions for HPI Complex Data Types *********************************************************/ /** * Check function for HPI struct SaHpiTextBufferT */ public static bool Check( SaHpiTextBufferT x ) { if ( x == null ) { return false; } if ( x.Data == null ) { return false; } if ( x.Data.Length != HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH ) { return false; } return true; }
public static SaHpiTextBufferT ToSaHpiTextBufferT( string s ) { // NB: Only BCD+/ASCII6/ASCII(Eng)/ are now supported. // TODO implement further SaHpiTextBufferT tb = new SaHpiTextBufferT(); tb.DataType = HpiConst.SAHPI_TL_TYPE_TEXT; tb.Language = HpiConst.SAHPI_LANG_ENGLISH; tb.DataLength = 0; tb.Data = new byte[HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH]; byte[] encoded = ascii.GetBytes( s ); tb.DataLength = Math.Min( encoded.Length, HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH ); Array.Copy( encoded, tb.Data, tb.DataLength ); return tb; }
public static SaHpiTextBufferT ToSaHpiTextBufferT(string s) { // NB: Only BCD+/ASCII6/ASCII(Eng)/ are now supported. // TODO implement further SaHpiTextBufferT tb = new SaHpiTextBufferT(); tb.DataType = HpiConst.SAHPI_TL_TYPE_TEXT; tb.Language = HpiConst.SAHPI_LANG_ENGLISH; tb.DataLength = 0; tb.Data = new byte[HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH]; byte[] encoded = ascii.GetBytes(s); tb.DataLength = Math.Min(encoded.Length, HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH); Array.Copy(encoded, tb.Data, tb.DataLength); return(tb); }
/********************************************************** * Text Buffer Helpers *********************************************************/ public static string FromSaHpiTextBufferT( SaHpiTextBufferT tb ) { // NB: Only BCD+/ASCII6/ASCII(Eng)/ are now supported. // TODO implement further bool ok = false; ok = ok || ( tb.DataType == HpiConst.SAHPI_TL_TYPE_BCDPLUS ); ok = ok || ( tb.DataType == HpiConst.SAHPI_TL_TYPE_ASCII6 ); bool eng = ( tb.Language == HpiConst.SAHPI_LANG_ENGLISH ); ok = ok || ( ( tb.DataType == HpiConst.SAHPI_TL_TYPE_TEXT ) && eng ); string s = null; if ( ok ) { char[] data = new char[tb.DataLength]; Array.Copy( tb.Data, data, tb.DataLength ); s = new string( data, 0, unchecked( (int)tb.DataLength ) ); } else { throw new FormatException(); } return s; }
public static long oHpiDomainAdd( SaHpiTextBufferT Host, int Port, SaHpiEntityPathT EntityRoot, out long DomainId ) { DomainId = 0; string s = HpiUtil.FromSaHpiTextBufferT( Host ); if ( s == null ) { return HpiConst.SA_ERR_HPI_INVALID_PARAMS; } HpiDomain d = HpiCore.CreateDomain( s, Port, EntityRoot ); if ( d == null ) { return HpiConst.SA_ERR_HPI_INTERNAL_ERROR; } DomainId = d.GetLocalDid(); return HpiConst.SA_OK; }
/********************************************************** * Marshal: For HPI Structs and Unions *********************************************************/ public void MarshalSaHpiTextBufferT( SaHpiTextBufferT x ) { MarshalSaHpiTextTypeT( x.DataType ); MarshalSaHpiLanguageT( x.Language ); MarshalSaHpiUint8T( x.DataLength ); MarshalByteArray( x.Data, HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH ); }
/********************************************************** * Demarshal: For HPI Structs and Unions *********************************************************/ public SaHpiTextBufferT DemarshalSaHpiTextBufferT() { SaHpiTextBufferT x = new SaHpiTextBufferT(); x.DataType = DemarshalSaHpiTextTypeT(); x.Language = DemarshalSaHpiLanguageT(); x.DataLength = DemarshalSaHpiUint8T(); x.Data = DemarshalByteArray( HpiConst.SAHPI_MAX_TEXT_BUFFER_LENGTH ); return x; }
public static long saHpiFumiSourceSet( long SessionId, long ResourceId, long FumiNum, long BankNum, SaHpiTextBufferT SourceUri ) { long rv; bool rc; rc = HpiUtil.Check( SourceUri ); if ( !rc ) { return HpiConst.SA_ERR_HPI_INVALID_PARAMS; } HpiSession s = HpiCore.GetSession( SessionId ); if ( s == null ) { return HpiConst.SA_ERR_HPI_INVALID_SESSION; } OhpiMarshal m = s.GetMarshal(); if ( m == null ) { return HpiConst.SA_ERR_HPI_NO_RESPONSE; } m.MarshalSaHpiSessionIdT( s.GetRemoteSid() ); m.MarshalSaHpiResourceIdT( ResourceId ); m.MarshalSaHpiFumiNumT( FumiNum ); m.MarshalSaHpiBankNumT( BankNum ); m.MarshalSaHpiTextBufferT( SourceUri ); rc = m.Interchange( OhpiConst.RPC_SAHPI_FUMI_SOURCE_SET ); if ( !rc ) { m.Close(); return HpiConst.SA_ERR_HPI_NO_RESPONSE; } rv = m.DemarshalSaErrorT(); if ( rv == HpiConst.SA_OK ) { // No output arguments } s.PutMarshal( m ); return rv; }
public static long saHpiDomainTagSet( long SessionId, SaHpiTextBufferT DomainTag ) { long rv; bool rc; rc = HpiUtil.Check( DomainTag ); if ( !rc ) { return HpiConst.SA_ERR_HPI_INVALID_PARAMS; } HpiSession s = HpiCore.GetSession( SessionId ); if ( s == null ) { return HpiConst.SA_ERR_HPI_INVALID_SESSION; } OhpiMarshal m = s.GetMarshal(); if ( m == null ) { return HpiConst.SA_ERR_HPI_NO_RESPONSE; } m.MarshalSaHpiSessionIdT( s.GetRemoteSid() ); m.MarshalSaHpiTextBufferT( DomainTag ); rc = m.Interchange( OhpiConst.RPC_SAHPI_DOMAIN_TAG_SET ); if ( !rc ) { m.Close(); return HpiConst.SA_ERR_HPI_NO_RESPONSE; } rv = m.DemarshalSaErrorT(); if ( rv == HpiConst.SA_OK ) { // No output arguments } s.PutMarshal( m ); return rv; }