Beispiel #1
0
 public static void RemoveSession(HpiSession s)
 {
     lock ( sessions )
     {
         sessions.Remove(s.GetLocalSid());
     }
     s.Close();
 }
Beispiel #2
0
            public static long saHpiSessionOpen(
                long DomainId,
                out long SessionId,
                Object SecurityParams
                )
            {
                long rv;
                bool rc;

                SessionId = 0;

                if (SecurityParams != null)
                {
                    return(HpiConst.SA_ERR_HPI_INVALID_PARAMS);
                }

                HpiSession s = HpiCore.CreateSession(DomainId);

                if (s == null)
                {
                    return(HpiConst.SA_ERR_HPI_INVALID_DOMAIN);
                }
                OhpiMarshal m = s.GetMarshal();

                if (m == null)
                {
                    HpiCore.RemoveSession(s);
                    return(HpiConst.SA_ERR_HPI_NO_RESPONSE);
                }

                m.MarshalSaHpiDomainIdT(s.GetRemoteDid());
                rc = m.Interchange(OhpiConst.RPC_SAHPI_SESSION_OPEN);
                if (!rc)
                {
                    m.Close();
                    HpiCore.RemoveSession(s);
                    return(HpiConst.SA_ERR_HPI_NO_RESPONSE);
                }
                rv = m.DemarshalSaErrorT();
                if (rv == HpiConst.SA_OK)
                {
                    SessionId = m.DemarshalSaHpiSessionIdT();
                    s.SetRemoteSid(SessionId);
                    SessionId = s.GetLocalSid();
                }
                s.PutMarshal(m);
                if (rv != HpiConst.SA_OK)
                {
                    HpiCore.RemoveSession(s);
                }

                return(rv);
            }
Beispiel #3
0
            public static HpiSession GetSession(long local_sid)
            {
                bool       rc;
                HpiSession s = null;

                lock ( sessions )
                {
                    rc = sessions.TryGetValue(local_sid, out s);
                }
                if (!rc)
                {
                    s = null;
                }
                return(s);
            }
Beispiel #4
0
            public static long oHpiHandlerCreate(
                long SessionId,
                oHpiHandlerConfigT HandlerConfig,
                out long HandlerId
                )
            {
                long rv;
                bool rc;

                HandlerId = HpiConst.SAHPI_LAST_ENTRY;

                rc = OhpiUtil.Check(HandlerConfig);
                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.MarshaloHpiHandlerConfigT(HandlerConfig);
                rc = m.Interchange(OhpiConst.RPC_OHPI_HANDLER_CREATE);
                if (!rc)
                {
                    m.Close();
                    return(HpiConst.SA_ERR_HPI_NO_RESPONSE);
                }
                rv = m.DemarshalSaErrorT();
                if (rv == HpiConst.SA_OK)
                {
                    HandlerId = m.DemarshaloHpiHandlerIdT();
                }
                s.PutMarshal(m);

                return(rv);
            }
Beispiel #5
0
            public static long oHpiHandlerInfo(
                long SessionId,
                long HandlerId,
                out oHpiHandlerInfoT HandlerInfo,
                out oHpiHandlerConfigT HandlerConfig
                )
            {
                long rv;
                bool rc;

                HandlerInfo   = null;
                HandlerConfig = null;

                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.MarshaloHpiHandlerIdT(HandlerId);
                rc = m.Interchange(OhpiConst.RPC_OHPI_HANDLER_INFO);
                if (!rc)
                {
                    m.Close();
                    return(HpiConst.SA_ERR_HPI_NO_RESPONSE);
                }
                rv = m.DemarshalSaErrorT();
                if (rv == HpiConst.SA_OK)
                {
                    HandlerInfo   = m.DemarshaloHpiHandlerInfoT();
                    HandlerConfig = m.DemarshaloHpiHandlerConfigT();
                }
                s.PutMarshal(m);

                return(rv);
            }
Beispiel #6
0
            public static long oHpiHandlerFind(
                long SessionId,
                long ResourceId,
                out long HandlerId
                )
            {
                long rv;
                bool rc;

                HandlerId = HpiConst.SAHPI_LAST_ENTRY;

                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);
                rc = m.Interchange(OhpiConst.RPC_OHPI_HANDLER_FIND);
                if (!rc)
                {
                    m.Close();
                    return(HpiConst.SA_ERR_HPI_NO_RESPONSE);
                }
                rv = m.DemarshalSaErrorT();
                if (rv == HpiConst.SA_OK)
                {
                    HandlerId = m.DemarshaloHpiHandlerIdT();
                }
                s.PutMarshal(m);

                return(rv);
            }
Beispiel #7
0
            public static long saHpiMyEntityPathGet(
                long SessionId,
                out SaHpiEntityPathT EntityPath
                )
            {
                EntityPath = null;

                HpiSession s = HpiCore.GetSession(SessionId);

                if (s == null)
                {
                    return(HpiConst.SA_ERR_HPI_INVALID_SESSION);
                }
                EntityPath = HpiCore.GetMyEntity();
                if (EntityPath == null)
                {
                    return(HpiConst.SA_ERR_HPI_UNKNOWN);
                }

                return(HpiConst.SA_OK);
            }
Beispiel #8
0
            public static long saHpiSessionClose(
                long SessionId
                )
            {
                long       rv;
                bool       rc;
                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());
                rc = m.Interchange(OhpiConst.RPC_SAHPI_SESSION_CLOSE);
                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);
                if (rv == HpiConst.SA_OK)
                {
                    HpiCore.RemoveSession(s);
                }

                return(rv);
            }
Beispiel #9
0
            public static HpiSession CreateSession(long local_did)
            {
                bool      rc;
                HpiDomain d = null;

                lock ( domains )
                {
                    rc = domains.TryGetValue(local_did, out d);
                }
                if (!rc)
                {
                    return(null);
                }
                HpiSession s = new HpiSession(d);

                lock ( sessions )
                {
                    sessions.Add(s.GetLocalSid(), s);
                }

                return(s);
            }
Beispiel #10
0
            public static long oHpiHandlerRetry(
                long SessionId,
                long HandlerId
                )
            {
                long rv;
                bool rc;

                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.MarshaloHpiHandlerIdT(HandlerId);
                rc = m.Interchange(OhpiConst.RPC_OHPI_HANDLER_RETRY);
                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);
            }
Beispiel #11
0
            public static long saHpiDimiTestStart(
                long SessionId,
                long ResourceId,
                long DimiNum,
                long TestNum,
                long NumberOfParams,
                SaHpiDimiTestVariableParamsT[] ParamsList
                )
            {
                long rv;
                bool rc;

                if (NumberOfParams != 0)
                {
                    if (ParamsList == null)
                    {
                        return(HpiConst.SA_ERR_HPI_INVALID_PARAMS);
                    }
                    if (NumberOfParams > ParamsList.Length)
                    {
                        return(HpiConst.SA_ERR_HPI_INVALID_PARAMS);
                    }
                    for (int i = 0; i < NumberOfParams; ++i)
                    {
                        rc = HpiUtil.Check(ParamsList[i]);
                        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.MarshalSaHpiDimiNumT(DimiNum);
                m.MarshalSaHpiDimiTestNumT(TestNum);
                m.MarshalSaHpiUint8T(NumberOfParams);
                for (int i = 0; i < NumberOfParams; ++i)
                {
                    m.MarshalSaHpiDimiTestVariableParamsT(ParamsList[i]);
                }
                rc = m.Interchange(OhpiConst.RPC_SAHPI_DIMI_TEST_START);
                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);
            }
Beispiel #12
0
 public static void RemoveSession( HpiSession s )
 {
     lock ( sessions )
     {
     sessions.Remove( s.GetLocalSid() );
     }
     s.Close();
 }
Beispiel #13
0
            public static HpiSession CreateSession( long local_did )
            {
                bool rc;
                HpiDomain d = null;
                lock ( domains )
                {
                rc = domains.TryGetValue( local_did, out d );
                }
                if ( !rc ) {
                return null;
                }
                HpiSession s = new HpiSession( d );
                lock ( sessions )
                {
                sessions.Add( s.GetLocalSid(), s );
                }

                return s;
            }