Example #1
0
            public static HpiDomain CreateDomain(string host,
                                                 int port,
                                                 SaHpiEntityPathT entity_root)
            {
                HpiDomain d = new HpiDomain(HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID,
                                            host,
                                            port,
                                            entity_root);
                bool ok = false;

                lock ( domains )
                {
                    for (long did = 0; did < long.MaxValue; ++did)
                    {
                        if (!domains.ContainsKey(did))
                        {
                            d.SetLocalDid(did);
                            domains[did] = d;
                            ok           = true;
                            break;
                        }
                    }
                }

                if (!ok)
                {
                    d = null;
                }

                return(d);
            }
Example #2
0
            public static HpiDomain CreateDomain( string host,
                                          int port,
                                          SaHpiEntityPathT entity_root )
            {
                HpiDomain d = new HpiDomain( HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID,
                                     host,
                                     port,
                                     entity_root );
                bool ok = false;

                lock ( domains )
                {
                for ( long did = 0; did < long.MaxValue; ++did ) {
                if ( !domains.ContainsKey( did ) ) {
                    d.SetLocalDid( did );
                    domains[did] = d;
                    ok = true;
                    break;
                }
                }
                }

                if ( !ok ) {
                d = null;
                }

                return d;
            }
Example #3
0
            private static void CreateDefaultDomain()
            {
                if (domains.ContainsKey(HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID))
                {
                    return;
                }
                string host = Environment.GetEnvironmentVariable("OPENHPI_DAEMON_HOST");

                if (host == null)
                {
                    host = "localhost";
                }
                int    port;
                string portstr = Environment.GetEnvironmentVariable("OPENHPI_DAEMON_PORT");

                if (portstr != null)
                {
                    try {
                        port = Convert.ToInt32(portstr);
                    } catch (FormatException) {
                        port = OhpiConst.DEFAULT_PORT;
                    }
                }
                else
                {
                    port = OhpiConst.DEFAULT_PORT;
                }
                HpiDomain d = new HpiDomain(HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID,
                                            host,
                                            port,
                                            HpiUtil.MakeRootSaHpiEntityPathT());

                domains[d.GetLocalDid()] = d;
            }
Example #4
0
 private static void CreateDefaultDomain()
 {
     if ( domains.ContainsKey( HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID ) ) {
     return;
     }
     string host = Environment.GetEnvironmentVariable( "OPENHPI_DAEMON_HOST" );
     if ( host == null ) {
     host = "localhost";
     }
     int port;
     string portstr = Environment.GetEnvironmentVariable( "OPENHPI_DAEMON_PORT" );
     if ( portstr != null ) {
     try {
     port = Convert.ToInt32( portstr );
     } catch ( FormatException ) {
     port = OhpiConst.DEFAULT_PORT;
     }
     } else {
     port = OhpiConst.DEFAULT_PORT;
     }
     HpiDomain d = new HpiDomain( HpiConst.SAHPI_UNSPECIFIED_DOMAIN_ID,
                          host,
                          port,
                          HpiUtil.MakeRootSaHpiEntityPathT() );
     domains[d.GetLocalDid()] = d;
 }
Example #5
0
            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);
            }
Example #6
0
 public HpiDomain(HpiDomain other)
 {
     this.local_did   = other.local_did;
     this.remote_did  = other.remote_did;
     this.remote_host = other.remote_host;
     this.remote_port = other.remote_port;
     this.entity_root = other.entity_root;
 }
Example #7
0
 public HpiDomain( HpiDomain other )
 {
     this.local_did   = other.local_did;
     this.remote_did  = other.remote_did;
     this.remote_host = other.remote_host;
     this.remote_port = other.remote_port;
     this.entity_root = other.entity_root;
 }
Example #8
0
 public HpiSession(HpiDomain domain)
 {
     // TODO investigate overflow issue
     this.local_sid  = Interlocked.Increment(ref cnt);
     this.remote_sid = 0;
     this.domain     = new HpiDomain(domain);
     this.marshals   = new LinkedList <OhpiMarshal>();
 }
Example #9
0
 public HpiSession( HpiDomain domain )
 {
     // TODO investigate overflow issue
     this.local_sid  = Interlocked.Increment( ref cnt );
     this.remote_sid = 0;
     this.domain     = new HpiDomain( domain );
     this.marshals   = new LinkedList<HpiMarshal>();
 }
Example #10
0
            /**********************************************************
             * Creates and returns new domain with specified Domain Id
             * Returns null if overwrite == false and
             * the specified Domain Id is already in use
             *********************************************************/
            public static HpiDomain CreateDomainById(long did,
                                                     string host,
                                                     int port,
                                                     SaHpiEntityPathT entity_root,
                                                     bool overwrite)
            {
                HpiDomain d = null;

                lock ( domains )
                {
                    if ((!domains.ContainsKey(did)) || overwrite)
                    {
                        d            = new HpiDomain(did, host, port, entity_root);
                        domains[did] = d;
                    }
                }

                return(d);
            }
Example #11
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);
            }
Example #12
0
            /**********************************************************
             * Creates and returns new domain with specified Domain Id
             * Returns null if overwrite == false and
             * the specified Domain Id is already in use
             *********************************************************/
            public static HpiDomain CreateDomainById( long did,
                                              string host,
                                              int port,
                                              SaHpiEntityPathT entity_root,
                                              bool overwrite )
            {
                HpiDomain d = null;

                lock ( domains )
                {
                if ( ( !domains.ContainsKey( did ) ) || overwrite ) {
                d = new HpiDomain( did, host, port, entity_root );
                domains[did] = d;
                }
                }

                return d;
            }