#!/bin/sh
# the next line restarts using wish \
exec wish8.3 "$0" "$@"

#lappend auto_path combat
#load ./libcombat.so
lappend auto_path /home/fp/soft/combat/orb
package require combat

set argv [eval corba::init $argv]

if {[llength $argv] != 1} {
	puts "usage: $argv0 <number of philosophers>"
	exit
}

set philosophers [lindex $argv 0]

if {$philosophers < 2 || $philosophers > 20} {
	puts "Number of philosophers must be 2<=x<=20"
	exit
}

#
# ----------------------------------------------------------------------
#
# Generated files here. Ignore this section (until the next --- line)
#

set alcatel "
R0lGODdhyAA2APIAAAAAAICAgP8AAP//AP///wAAAAAAAAAAACwAAAAAyAA2AAAD/ki63P4wykmp
uOGKjHWuYCiOZGmeaDQIa8u+birPdG3fijZw67X7uKBwSJwJCC/kSnksOp/QKJKz8Xik2Kz25Oom
t+CwuPHy8S7jtDqbbA/W8DjR2mnK73iZd5nv+0dnQH+DhBFHbYWJilNXi46DXY+SfSwfk5d3X5ib
amicn2lvoKOkpaanqKmqq6ytrq+wsbKztLW2swABubu6vby/vsHAw8LFxMfGycjLys3Mz87R0Ly6
ALvW1dfa2dzW297d2ODj4uXf5uHn6uns5Ovu7ejw8/L12tPS+fj7+v38//4C4vMljuCwgt8MCkPY
TeEvhuMcSkxIsWHFiBchajzI/nFhR4gCQwLktUCkyZEnUyKL985ePAYt30FwSS9mugo1uUWgWQ4m
y3QACYhkMHSmQAJBKejbubTkyI8KFWTsCHOjxwAOcjm1+hCAgokWdeEMGzECWYY+py70t2AkUX5p
fSEN6LTo3H9t7QoF+HNc1b498+YE14Cnzao24W1NjG0x4GtpDWeD+5Zt3WmVUe4qbNetVL0hwZbl
rJak4LOmkUIt7eBq14WXuRKMvVpnW9nnmpLWvVe35mAPOh81ivlyv8dEHQ/2KliycsnkiENv/HX5
tp2MIzMGScxpZmnfn53WzBTvZ/N3h1cXWDvteNRYb9e2Rtv1RAm4G962n3D/u+v/vcSF0Vng4ceb
ZeuhNIF6nqWHXm/89EXBdNr9VNh2tuE3nVbVbRjfXh7S19x20FT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c5jEwz4TgAFa+CAy4CiS2QQdlLIFJHIGm/Zdx5QIjlBXoDAKqvAKWLkL
v8ABA1EGatAG8DkaYYAFTpB4KaABJEU8DcA9ejEDtZEEUXAFXOBaakBCa3cGHBUFR8ADLxACFsCb
BhABIMACmxEF0sYGcTAHcaAGYVAFR3ADIzAB6YKYDDABHYBAM5ADQXAEQ5VWYpBUYRAGaekERKAD
LgACEeCGOuoQAQEAOw==
"

set forkimg "
R0lGODlhFAAaAOMAANTU1BsgHyYnJxQYF9fX1tfX1x4jJAAAABsfIKysrBATEwQFBbq6uhAUE9jY
2NbW1SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAAFAAaAAAEUxDISau9OOeAufYU+FGCuFGDiQnDpJ4E
8HZAIWsVGBy4ZOg8ymGYE5mIOUQoKEG6VAqkUzYbLHjIgFYzbGi/s9D3EL5se0V0Wh1it92SMnzi
mD8iADs=
"

set nofork "
R0lGODlhFAAaAKUAAPewsNTU1BsgHzMEAyYnJxQYF0YFBdfX1tfX1/eurverqx4jJAAAAPevr9TT
0+PDw/etrdnOzhsfIKysrNjPz/epqdvMzBATE9XS0gcAAAEBAe2MjPmenh8CAj8ODW4WFjcIB9jY
2NbW1f//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////yH+Dk1hZGUgd2l0aCBHSU1QACwAAAAA
FAAaAAAGekCAMEAsGo3CJODIJCqVTeQT0KhGA9TGEKvdHpNaYzXJBDO7XqywEYUW3c2nOl2ekq/z
hOKOVzcSdFEODxB/ABF9RBQAEAkNFRaJahAQexiJVVocWX2ZnlZXWaCZS218c6Vfp6ipTnBvcHJx
fK91W6u2Q7i5ASGSqCJBADs=
"

#
# This file was automatically generated from CosNaming.idl
# by idl2tcl. Do not edit.
#

set _ir_CosNaming \
{{module {IDL:omg.org/CosNaming:1.0 CosNaming 1.0} {{interface\
{IDL:omg.org/CosNaming/BindingIterator:1.0 BindingIterator 1.0}} {typedef\
{IDL:omg.org/CosNaming/Istring:1.0 Istring 1.0} string} {struct\
{IDL:omg.org/CosNaming/NameComponent:1.0 NameComponent 1.0} {{id\
IDL:omg.org/CosNaming/Istring:1.0} {kind IDL:omg.org/CosNaming/Istring:1.0}}\
{}} {typedef {IDL:omg.org/CosNaming/Name:1.0 Name 1.0} {sequence\
IDL:omg.org/CosNaming/NameComponent:1.0}} {enum\
{IDL:omg.org/CosNaming/BindingType:1.0 BindingType 1.0} {nobject ncontext}}\
{struct {IDL:omg.org/CosNaming/Binding:1.0 Binding 1.0} {{binding_name\
IDL:omg.org/CosNaming/Name:1.0} {binding_type\
IDL:omg.org/CosNaming/BindingType:1.0}} {}} {typedef\
{IDL:omg.org/CosNaming/BindingList:1.0 BindingList 1.0} {sequence\
IDL:omg.org/CosNaming/Binding:1.0}} {interface\
{IDL:omg.org/CosNaming/NamingContext:1.0 NamingContext 1.0} {} {{enum\
{IDL:omg.org/CosNaming/NamingContext/NotFoundReason:1.0 NotFoundReason 1.0}\
{missing_node not_context not_object}} {exception\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0 NotFound 1.0} {{why\
IDL:omg.org/CosNaming/NamingContext/NotFoundReason:1.0} {rest_of_name\
IDL:omg.org/CosNaming/Name:1.0}} {}} {exception\
{IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0 CannotProceed 1.0}\
{{cxt IDL:omg.org/CosNaming/NamingContext:1.0} {rest_of_name\
IDL:omg.org/CosNaming/Name:1.0}} {}} {exception\
{IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0 InvalidName 1.0} {} {}}\
{exception {IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0 AlreadyBound\
1.0} {} {}} {exception {IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0\
NotEmpty 1.0} {} {}} {operation {IDL:omg.org/CosNaming/NamingContext/bind:1.0\
bind 1.0} void {{in n IDL:omg.org/CosNaming/Name:1.0} {in obj Object}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0\
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/rebind:1.0 rebind 1.0} void {{in n\
IDL:omg.org/CosNaming/Name:1.0} {in obj Object}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/bind_context:1.0 bind_context 1.0} void\
{{in n IDL:omg.org/CosNaming/Name:1.0} {in nc\
IDL:omg.org/CosNaming/NamingContext:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0\
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/rebind_context:1.0 rebind_context 1.0}\
void {{in n IDL:omg.org/CosNaming/Name:1.0} {in nc\
IDL:omg.org/CosNaming/NamingContext:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/resolve:1.0 resolve 1.0} Object {{in n\
IDL:omg.org/CosNaming/Name:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/unbind:1.0 unbind 1.0} void {{in n\
IDL:omg.org/CosNaming/Name:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/new_context:1.0 new_context 1.0}\
IDL:omg.org/CosNaming/NamingContext:1.0 {} {}} {operation\
{IDL:omg.org/CosNaming/NamingContext/bind_new_context:1.0 bind_new_context\
1.0} IDL:omg.org/CosNaming/NamingContext:1.0 {{in n\
IDL:omg.org/CosNaming/Name:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContext/destroy:1.0 destroy 1.0} void {}\
IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0} {operation\
{IDL:omg.org/CosNaming/NamingContext/list:1.0 list 1.0} void {{in how_many\
{unsigned long}} {out bl IDL:omg.org/CosNaming/BindingList:1.0} {out bi\
IDL:omg.org/CosNaming/BindingIterator:1.0}} {}}}} {interface\
{IDL:omg.org/CosNaming/BindingIterator:1.0 BindingIterator 1.0} {}\
{{operation {IDL:omg.org/CosNaming/BindingIterator/next_one:1.0 next_one 1.0}\
boolean {{out b IDL:omg.org/CosNaming/Binding:1.0}} {}} {operation\
{IDL:omg.org/CosNaming/BindingIterator/next_n:1.0 next_n 1.0} boolean {{in\
how_many {unsigned long}} {out bl IDL:omg.org/CosNaming/BindingList:1.0}} {}}\
{operation {IDL:omg.org/CosNaming/BindingIterator/destroy:1.0 destroy 1.0}\
void {} {}}}} {interface {IDL:omg.org/CosNaming/NamingContextExt:1.0\
NamingContextExt 1.0} IDL:omg.org/CosNaming/NamingContext:1.0 {{typedef\
{IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0 StringName 1.0}\
string} {typedef {IDL:omg.org/CosNaming/NamingContextExt/Address:1.0 Address\
1.0} string} {typedef {IDL:omg.org/CosNaming/NamingContextExt/URLString:1.0\
URLString 1.0} string} {operation\
{IDL:omg.org/CosNaming/NamingContextExt/to_string:1.0 to_string 1.0}\
IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0 {{in n\
IDL:omg.org/CosNaming/Name:1.0}}\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0} {operation\
{IDL:omg.org/CosNaming/NamingContextExt/to_name:1.0 to_name 1.0}\
IDL:omg.org/CosNaming/Name:1.0 {{in sn\
IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0}}\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0} {exception\
{IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0 InvalidAddress\
1.0} {} {}} {operation {IDL:omg.org/CosNaming/NamingContextExt/to_url:1.0\
to_url 1.0} IDL:omg.org/CosNaming/NamingContextExt/URLString:1.0 {{in addr\
IDL:omg.org/CosNaming/NamingContextExt/Address:1.0} {in sn\
IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0}}\
{IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0}} {operation\
{IDL:omg.org/CosNaming/NamingContextExt/resolve_str:1.0 resolve_str 1.0}\
Object {{in n IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0}}\
{IDL:omg.org/CosNaming/NamingContext/NotFound:1.0\
IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0\
IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0\
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0}}}}}}}

#
# This file was automatically generated from philo.idl
# by idl2tcl. Do not edit.
#

set _ir_philo \
{{module {IDL:Components:1.0 Components 1.0} {{interface\
{IDL:Components/CCMObject:1.0 CCMObject 1.0}} {interface\
{IDL:Components/CCMHome:1.0 CCMHome 1.0}}}} {module {IDL:Dinner:1.0 Dinner\
1.0} {{interface {IDL:Dinner/Registrator:1.0 Registrator 1.0}} {interface\
{IDL:Dinner/Cutlery:1.0 Cutlery 1.0}} {interface {IDL:Dinner/Registration:1.0\
Registration 1.0}} {interface {IDL:Dinner/Philosopher:1.0 Philosopher 1.0}}\
{interface {IDL:Dinner/Chopstick:1.0 Chopstick 1.0}}}} {module\
{IDL:Components:1.0 Components 1.0} {{typedef {IDL:Components/FeatureName:1.0\
FeatureName 1.0} string} {typedef {IDL:Components/NameList:1.0 NameList 1.0}\
{sequence IDL:Components/FeatureName:1.0}} {exception\
{IDL:Components/InvalidName:1.0 InvalidName 1.0} {} {}} {struct\
{IDL:Components/FacetDescription:1.0 FacetDescription 1.0} {{InterfaceID\
string} {Name IDL:Components/FeatureName:1.0}} {}} {struct\
{IDL:Components/Facet:1.0 Facet 1.0} {{InterfaceID string} {Name\
IDL:Components/FeatureName:1.0} {ref Object}} {}} {typedef\
{IDL:Components/Facets:1.0 Facets 1.0} {sequence IDL:Components/Facet:1.0}}\
{typedef {IDL:Components/FacetDescriptions:1.0 FacetDescriptions 1.0}\
{sequence IDL:Components/FacetDescription:1.0}} {interface\
{IDL:Components/Navigation:1.0 Navigation 1.0} {} {{operation\
{IDL:Components/Navigation/provide_facet:1.0 provide_facet 1.0} Object {{in\
name IDL:Components/FeatureName:1.0}} IDL:Components/InvalidName:1.0}\
{operation {IDL:Components/Navigation/describe_facets:1.0 describe_facets\
1.0} IDL:Components/FacetDescriptions:1.0 {} {}} {operation\
{IDL:Components/Navigation/provide_all_facets:1.0 provide_all_facets 1.0}\
IDL:Components/Facets:1.0 {} {}} {operation\
{IDL:Components/Navigation/provide_named_facets:1.0 provide_named_facets 1.0}\
IDL:Components/Facets:1.0 {{in names IDL:Components/NameList:1.0}}\
IDL:Components/InvalidName:1.0} {operation\
{IDL:Components/Navigation/same_component:1.0 same_component 1.0} boolean\
{{in ref Object}} {}}}} {struct {IDL:Components/Cookie:1.0 Cookie 1.0}\
{{CookieValue {sequence octet}}} {}} {struct\
{IDL:Components/ConnectionDescription:1.0 ConnectionDescription 1.0} {{ck\
IDL:Components/Cookie:1.0} {objref Object}} {}} {exception\
{IDL:Components/AlreadyConnected:1.0 AlreadyConnected 1.0} {} {}} {exception\
{IDL:Components/InvalidConnection:1.0 InvalidConnection 1.0} {} {}}\
{exception {IDL:Components/NoConnection:1.0 NoConnection 1.0} {} {}}\
{exception {IDL:Components/ExceededConnectionLimit:1.0\
ExceededConnectionLimit 1.0} {} {}} {exception\
{IDL:Components/CookieRequired:1.0 CookieRequired 1.0} {} {}} {typedef\
{IDL:Components/ConnectionDescriptions:1.0 ConnectionDescriptions 1.0}\
{sequence IDL:Components/ConnectionDescription:1.0}} {interface\
{IDL:Components/Receptacles:1.0 Receptacles 1.0} {} {{operation\
{IDL:Components/Receptacles/connect:1.0 connect 1.0}\
IDL:Components/Cookie:1.0 {{in name IDL:Components/FeatureName:1.0} {in\
connection Object}} {IDL:Components/InvalidName:1.0\
IDL:Components/InvalidConnection:1.0 IDL:Components/AlreadyConnected:1.0\
IDL:Components/ExceededConnectionLimit:1.0}} {operation\
{IDL:Components/Receptacles/disconnect:1.0 disconnect 1.0} void {{in name\
IDL:Components/FeatureName:1.0} {in ck IDL:Components/Cookie:1.0}}\
{IDL:Components/InvalidName:1.0 IDL:Components/InvalidConnection:1.0\
IDL:Components/CookieRequired:1.0 IDL:Components/NoConnection:1.0}}\
{operation {IDL:Components/Receptacles/get_connections:1.0 get_connections\
1.0} IDL:Components/ConnectionDescriptions:1.0 {{in name\
IDL:Components/FeatureName:1.0}} IDL:Components/InvalidName:1.0}}} {interface\
{IDL:Components/Events:1.0 Events 1.0} {} {}} {interface\
{IDL:Components/CCMHome:1.0 CCMHome 1.0} {} {{operation\
{IDL:Components/CCMHome/get_component_def:1.0 get_component_def 1.0} Object\
{} {}} {operation {IDL:Components/CCMHome/get_home_def:1.0 get_home_def 1.0}\
Object {} {}} {operation {IDL:Components/CCMHome/remove_component:1.0\
remove_component 1.0} void {{in comp IDL:Components/CCMObject:1.0}} {}}}}\
{interface {IDL:Components/CCMObject:1.0 CCMObject 1.0}\
{IDL:Components/Navigation:1.0 IDL:Components/Receptacles:1.0\
IDL:Components/Events:1.0} {{operation\
{IDL:Components/CCMObject/get_component_def:1.0 get_component_def 1.0} Object\
{} {}} {operation {IDL:Components/CCMObject/get_ccm_home:1.0 get_ccm_home\
1.0} IDL:Components/CCMHome:1.0 {} {}} {operation\
{IDL:Components/CCMObject/configuration_complete:1.0 configuration_complete\
1.0} void {} {}} {operation {IDL:Components/CCMObject/remove:1.0 remove 1.0}\
void {} {}}}} {exception {IDL:Components/DuplicateKeyValue:1.0\
DuplicateKeyValue 1.0} {} {}} {exception {IDL:Components/UnknownKeyValue:1.0\
UnknownKeyValue 1.0} {} {}} {exception {IDL:Components/InvalidKey:1.0\
InvalidKey 1.0} {} {}} {interface {IDL:Components/KeylessCCMHome:1.0\
KeylessCCMHome 1.0} {} {{operation\
{IDL:Components/KeylessCCMHome/create_component:1.0 create_component 1.0}\
IDL:Components/CCMObject:1.0 {} {}}}} {exception\
{IDL:Components/HomeNotFound:1.0 HomeNotFound 1.0} {} {}} {interface\
{IDL:Components/HomeFinder:1.0 HomeFinder 1.0} {} {{operation\
{IDL:Components/HomeFinder/find_home_by_component_type:1.0\
find_home_by_component_type 1.0} IDL:Components/CCMHome:1.0 {{in comp_repid\
string}} IDL:Components/HomeNotFound:1.0} {operation\
{IDL:Components/HomeFinder/find_home_by_home_type:1.0 find_home_by_home_type\
1.0} IDL:Components/CCMHome:1.0 {{in home_repid string}}\
IDL:Components/HomeNotFound:1.0} {operation\
{IDL:Components/HomeFinder/find_home_by_name:1.0 find_home_by_name 1.0}\
IDL:Components/CCMHome:1.0 {{in home_name string}} {}}}} {exception\
{IDL:Components/IllegalState:1.0 IllegalState 1.0} {} {}} {enum\
{IDL:Components/CCMExceptionReason:1.0 CCMExceptionReason 1.0} {SYSTEM_ERROR\
CREATE_ERROR REMOVE_ERROR DUPLICATE_KEY FIND_ERROR OBJECT_NOT_FOUND\
NO_SUCH_ENTITY}} {exception {IDL:Components/CCMException:1.0 CCMException\
1.0} {{reason IDL:Components/CCMExceptionReason:1.0}} {}}}} {module\
{IDL:Dinner:1.0 Dinner 1.0} {{exception {IDL:Dinner/InUse:1.0 InUse 1.0} {}\
{}} {interface {IDL:Dinner/Cutlery:1.0 Cutlery 1.0} {} {{operation\
{IDL:Dinner/Cutlery/get:1.0 get 1.0} void {} IDL:Dinner/InUse:1.0} {operation\
{IDL:Dinner/Cutlery/release:1.0 release 1.0} void {} {}}}} {interface\
{IDL:Dinner/Registration:1.0 Registration 1.0} {} {{operation\
{IDL:Dinner/Registration/register:1.0 register 1.0} string {} {}}}}\
{interface {IDL:Dinner/Registrator:1.0 Registrator 1.0}\
{IDL:Components/CCMObject:1.0 IDL:Dinner/Registration:1.0} {}} {interface\
{IDL:Dinner/RegTPExplicit:1.0 RegTPExplicit 1.0} IDL:Components/CCMHome:1.0\
{}} {interface {IDL:Dinner/RegTPImplicit:1.0 RegTPImplicit 1.0}\
IDL:Components/KeylessCCMHome:1.0 {{operation\
{IDL:Dinner/RegTPImplicit/create:1.0 create 1.0} IDL:Dinner/Registrator:1.0\
{} {}}}} {interface {IDL:Dinner/RegTP:1.0 RegTP 1.0}\
{IDL:Dinner/RegTPExplicit:1.0 IDL:Dinner/RegTPImplicit:1.0} {}} {struct\
{IDL:Dinner/Status:1.0 Status 1.0} {{hungry {unsigned long}} {has_left_fork\
boolean} {has_right_fork boolean}} {}} {interface {IDL:Dinner/Philosopher:1.0\
Philosopher 1.0} IDL:Components/CCMObject:1.0 {{operation\
{IDL:Dinner/Philosopher/connect_left:1.0 connect_left 1.0} void {{in conxn\
IDL:Dinner/Cutlery:1.0}} {IDL:Components/AlreadyConnected:1.0\
IDL:Components/InvalidConnection:1.0}} {operation\
{IDL:Dinner/Philosopher/disconnect_left:1.0 disconnect_left 1.0}\
IDL:Dinner/Cutlery:1.0 {} IDL:Components/NoConnection:1.0} {operation\
{IDL:Dinner/Philosopher/get_connection_left:1.0 get_connection_left 1.0}\
IDL:Dinner/Cutlery:1.0 {} {}} {operation\
{IDL:Dinner/Philosopher/connect_right:1.0 connect_right 1.0} void {{in conxn\
IDL:Dinner/Cutlery:1.0}} {IDL:Components/AlreadyConnected:1.0\
IDL:Components/InvalidConnection:1.0}} {operation\
{IDL:Dinner/Philosopher/disconnect_right:1.0 disconnect_right 1.0}\
IDL:Dinner/Cutlery:1.0 {} IDL:Components/NoConnection:1.0} {operation\
{IDL:Dinner/Philosopher/get_connection_right:1.0 get_connection_right 1.0}\
IDL:Dinner/Cutlery:1.0 {} {}} {operation\
{IDL:Dinner/Philosopher/connect_register:1.0 connect_register 1.0} void {{in\
conxn IDL:Dinner/Registration:1.0}} {IDL:Components/AlreadyConnected:1.0\
IDL:Components/InvalidConnection:1.0}} {operation\
{IDL:Dinner/Philosopher/disconnect_register:1.0 disconnect_register 1.0}\
IDL:Dinner/Registration:1.0 {} IDL:Components/NoConnection:1.0} {operation\
{IDL:Dinner/Philosopher/get_connection_register:1.0 get_connection_register\
1.0} IDL:Dinner/Registration:1.0 {} {}} {attribute\
{IDL:Dinner/Philosopher/name:1.0 name 1.0} string readonly} {attribute\
{IDL:Dinner/Philosopher/howami:1.0 howami 1.0} IDL:Dinner/Status:1.0\
readonly}}} {interface {IDL:Dinner/PhilosopherHomeExplicit:1.0\
PhilosopherHomeExplicit 1.0} IDL:Components/CCMHome:1.0 {}} {interface\
{IDL:Dinner/PhilosopherHomeImplicit:1.0 PhilosopherHomeImplicit 1.0}\
IDL:Components/KeylessCCMHome:1.0 {{operation\
{IDL:Dinner/PhilosopherHomeImplicit/create:1.0 create 1.0}\
IDL:Dinner/Philosopher:1.0 {} {}}}} {interface\
{IDL:Dinner/PhilosopherHome:1.0 PhilosopherHome 1.0}\
{IDL:Dinner/PhilosopherHomeExplicit:1.0\
IDL:Dinner/PhilosopherHomeImplicit:1.0} {}} {interface\
{IDL:Dinner/Chopstick:1.0 Chopstick 1.0} {IDL:Components/CCMObject:1.0\
IDL:Dinner/Cutlery:1.0} {}} {interface {IDL:Dinner/ChopstickHomeExplicit:1.0\
ChopstickHomeExplicit 1.0} IDL:Components/CCMHome:1.0 {}} {interface\
{IDL:Dinner/ChopstickHomeImplicit:1.0 ChopstickHomeImplicit 1.0}\
IDL:Components/KeylessCCMHome:1.0 {{operation\
{IDL:Dinner/ChopstickHomeImplicit/create:1.0 create 1.0}\
IDL:Dinner/Chopstick:1.0 {} {}}}} {interface {IDL:Dinner/ChopstickHome:1.0\
ChopstickHome 1.0} {IDL:Dinner/ChopstickHomeExplicit:1.0\
IDL:Dinner/ChopstickHomeImplicit:1.0} {}}}}}

#
# ----------------------------------------------------------------------
#

wm title . "Combat Dining Philosophers"
menu .menu -tearoff 0
.menu add cascade -label "File" -menu .menu.file -underline 0
menu .menu.file -tearoff 0
.menu.file add command -label "Exit" -command "exit" -underline 0

frame .title -relief raised -bd 2
label .title.text -justify center -text "Dining Philosophers CCM Demo" \
	-font -Adobe-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*
pack .title.text -fill both -padx 10 -pady 5 -side top
pack .title -fill x -side top

frame .logos -background "#ffffff"
frame .logos.both -background "#ffffff"
set fpxpic [image create photo -data $fpx]
set alcatelpic [image create photo -data $alcatel]
label .logos.both.alcatel -image $alcatelpic -background "#ffffff"
label .logos.both.fpx -image $fpxpic -background "#ffffff"
pack .logos.both.alcatel .logos.both.fpx -side left -padx 10 \
	-expand true -fill both
pack .logos.both -anchor center -expand true -fill both
pack .logos -side top -expand true -fill both -anchor center

set forkpic [image create photo -data $forkimg]
set noforkpic [image create photo -data $nofork]

frame .philo
for {set i 0} {$i < $philosophers} {incr i} {
    frame .philo.$i -relief sunken -bd 1
    label .philo.$i.name -justify left -anchor w -width 18 \
	    -text "Philosopher # [expr $i + 1]" -foreground "#808080"
    label .philo.$i.left -justify center -anchor center -image $noforkpic \
	    -width 20 -height 26
    label .philo.$i.right -justify center -anchor center -image $noforkpic \
	    -width 20 -height 26
    label .philo.$i.hungry -justify left -anchor w -width 30 \
	    -text "" -foreground "#008000"
    pack .philo.$i.name .philo.$i.left .philo.$i.right \
	    -side left -padx 2 -pady 2
    pack .philo.$i.hungry -fill x -expand true
    pack .philo.$i -fill x -side top -padx 2
    frame .philo.filler-$i -relief raised -bd 1
    pack .philo.filler-$i -side top -pady 1 -fill x
}

pack .philo -fill x

frame .status -relief raised -bd 2
label .status.left -justify left -anchor w -width 30
label .status.right -justify right -anchor e -width 20
pack .status.left -fill x -side left -expand true
pack .status.right -side right
pack .status -side bottom -fill x

#
# ----------------------------------------------------------------------
#

.status.left configure -text "Initializing Combat ... "
update

combat::ir add $_ir_CosNaming
combat::ir add $_ir_philo

after 1000

#
# ----------------------------------------------------------------------
#

.status.left configure -text "Contacting the Naming Service ..."
update

set ns [corba::resolve_initial_references NameService]
set RegHome [$ns resolve_str RegTP]
set ForkHome [$ns resolve_str ChopstickHome]
set PhiloHome [$ns resolve_str PhilosopherHome]
set reg [$RegHome create]

for {set i 0} {$i < $philosophers} {incr i} {
    .status.left configure -text "Creating Forks ... $i"
    update
    after 200
    set fork($i) [$ForkHome create]
}

for {set i 0} {$i < $philosophers} {incr i} {
    .status.left configure -text "Creating Philosophers ... $i"
    update
    after 200
    set philo($i) [$PhiloHome create]
}

for {set i 0} {$i < $philosophers} {incr i} {
    .status.left configure -text "Configuring Philosophers ... $i"
    update
    after 200

    $philo($i) connect_register $reg
    $philo($i) connect_left $fork($i)
    $philo($i) connect_right $fork([expr ($i+1)%$philosophers])

    .philo.$i.name configure -foreground "#000000"
    update
}

.status.left configure -text "Running ..."

proc UpdateProc {} {
    global philo philosophers forkpic noforkpic

    for {set i 0} {$i < $philosophers} {incr i} {
	array set status [$philo($i) howami]
	if {$status(has_left_fork)} {
	    .philo.$i.left configure -image $forkpic
	} else {
	    .philo.$i.left configure -image $noforkpic
	}
	if {$status(has_right_fork)} {
	    .philo.$i.right configure -image $forkpic
	} else {
	    .philo.$i.right configure -image $noforkpic
	}

	set hungry "oooooooooooooooooooooooooooooooooooooooo"
	set hungry [string range $hungry 0 $status(hungry)]

	if {$status(hungry) < 3} {
	    set color "#000000"
	} elseif {$status(hungry) < 10} {
	    set color "#008000"
	} elseif {$status(hungry) < 25} {
	    set color "#FFFF00"
	} else {
	    set color "#FF0000"
	}

	.philo.$i.hungry configure -text $hungry -foreground $color
    }

    after 200 UpdateProc
}

after 200 UpdateProc
vwait forever
