rozważania o CNC

Marzec 29, 2024, 12:20:15
Witamy, Gość. Zaloguj się lub zarejestruj.

Zaloguj się podając nazwę użytkownika, hasło i długość sesji
Strony: [1]   Do dołu
  Drukuj  
Autor Wątek: NGCGUI  (Przeczytany 40876 razy)
markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« : Styczeń 08, 2012, 04:47:14 »

NGCGUI
na podstawie dokumentacji emc2 2.5 (ngcgui_pl.txt (jeszcze nie przetłumaczone)

= NGCGUI

image::images/ngcgui.png[]

== Overview
   
 - ngcgui is a subroutine utility for writing and using EMC subroutines
 - ngcgui can run as a standalone application or be embedded in
 - multiple tab pages in the axis gui

ngcgui is a powerful tool for building g-code programs from subroutines.
Subroutines can be concatenated to build a complete program. Multiple
instances of a subroutine can be used to perform the same task in different
locations on the part. Any valid g-code can be used in the subroutine.

== Embedding ngcgui in Axis

This is an example of embedding ngcgui into Axis. The subroutines need to be
in the subdirectories as shown if you just copy this. Some example subroutines
use other subroutines so check to be sure you have the dependences if any in
your subroutine directory.

----
[DISPLAY]
TKPKG             = Ngcgui    1.0
TKPKG             = Ngcguittt 1.0
# Ngcgui must precede Ngcguittt

NGCGUI_FONT       = Helvetica -12 normal
# specify relative or full path for startup subroutine tab pages:
NGCGUI_PREAMBLE   = ../../nc_files/ngcgui_lib/utilitysubs/in_std.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/simp.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/xyz.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/iquad.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/db25.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/ihex.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/gosper.ngc
# specify "" for a custom tab page
NGCGUI_SUBFILE    = ""
#NGCGUI_SUBFILE   = "" use when image frame is specified if
#                      opening other files is required
#                      images will be put in a top level window
NGCGUI_OPTIONS    =
#NGCGUI_OPTIONS   = opt1 opt2 ...
# opt items:
#   nonew      -- disallow making a new custom tab
#   noremove   -- disallow removing any tab page
#   noauto     -- no auto send (makeFile, then manually send)
#   noiframe   -- no internal image, image  on separate top level

TTT               = truetype-tracer
TTT_PREAMBLE      = ../../nc_files/ngcgui_lib/utilitysubs/in_std.ngc

PROGRAM_PREFIX          = ../../nc_files
----

== DB25 Example

The following shows the DB25 subroutine. In the first photo you see where you
fill in the blanks for each variable.

image::images/ngcgui-db25-1.png[]

This photo shows the backplot of the DB25 subroutine.

image::images/ngcgui-db25-2.png[]

This photo shows the use of the new button and the custom tab to create
three DB25 cutouts in one program.

image::images/ngcgui-db25-3.png[]


== Creating a Subroutine

Creating a subroutine for use with ngcgui requires that the file name and the
subroutine be named the same. The file must be in the subdirectory pointed to in
the ini file. In the first line you can have a comment identified by info: and
it will be added to the top of the subroutine. The subroutine must be
surrounded by the sub/endsub tags. The variables used in your subroutine must
be assigned number variables and not skip any numbers. Comments and presets can
be included.

----
(info: simp -- simple subroutine example -- Ctrl-U to edit)
o<simp> sub
  #<ra>       = #1 (=.6 Radius A) ;Example parm with a comment
  #<radius_b> = #2 (=0.4)         ;Example parm with no comment
  #<feedrate> = #3 (Feedrate)     ;Example parm with no preset
  g0x0y0z1
  g3 i#<ra> f#<feedrate>
  g3 i[0-#<radius_b>]
o<simp> endsub
----

Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #1 : Styczeń 08, 2012, 04:54:40 »

plik ngcgui.txt

--------------------------------------------------

= NGCGUI

image::images/ngcgui.png[]

== Overview
   
* 'NGCGUI' is a utility for using EMC2 subroutines.
* 'NGCGUI' can run as a standalone application or be embedded in
   multiple tab pages in the axis gui
* Multiple copies of the same subroutine can be created
* Subroutines can be concatenated together to form a complete multiple
  step program
* New subroutines can be added on the fly

NGCGUI is a powerful tool for building g-code programs from subroutines
on the fly.
Subroutines can be concatenated to build a complete program. Multiple
instances of a subroutine can be used to perform the same task in different
locations on the part. Any valid g-code can be used in the subroutine.

== Embedding NGCGUI in Axis

Several NGCGUI examples are included with EMC2 and are located in the sim/ngcgui
directory.

=== INI File

The following INI file items for NGCGUI go in the [DISPLAY] section.

* 'TKPKG = Ngcgui 1.0' - the main NGCGUI package (must precede Ngcguittt)
* 'TKPKG = Ngcguittt 1.0' - the True Type Tracer package for generating text
   for engraving.
* 'NGCGUI_FONT = Helvetica -12 normal' - specifices the font
* 'NGCGUI_PREAMBLE = in_std.ngc' - the preamble file to be added in front of the
  subroutines. When concatenating several subroutines this is only added once.
* 'NGCGUI_SUBFILE = simp.ngc' - creates a tab from the named subroutine
* 'NGCGUI_SUBFILE = ""' - creates a custom tab
* 'NGCGUI_OPTIONS = opt1 opt2 ...' - NGCGUI options
** 'nonew' - disallow making a new custom tab
** 'noremove' - disallow removing any tab page
** 'noauto' - no auto send (makeFile, then manually send)
** 'noiframe' - no internal image, image on separate top level
* 'TTT = truetype-tracer' - the truetype tracer program
* 'TTT_PREAMBLE = in_std.ngc' -

This is an example of embedding NGCGUI into Axis. The subroutines need to be
in the subdirectories as shown if you just copy this. Some example subroutines
use other subroutines so check to be sure you have the dependences if any in
your subroutine directory.

.Sample INI
----
[DISPLAY]
TKPKG             = Ngcgui    1.0
TKPKG             = Ngcguittt 1.0
# Ngcgui must precede Ngcguittt

NGCGUI_FONT       = Helvetica -12 normal
# specify relative or full path for startup subroutine tab pages:
NGCGUI_PREAMBLE   = ../../nc_files/ngcgui_lib/utilitysubs/in_std.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/simp.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/xyz.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/iquad.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/db25.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/ihex.ngc
NGCGUI_SUBFILE    = ../../nc_files/ngcgui_lib/gosper.ngc
# specify "" for a custom tab page
NGCGUI_SUBFILE    = ""
#NGCGUI_SUBFILE   = "" use when image frame is specified if
#                      opening other files is required
#                      images will be put in a top level window
NGCGUI_OPTIONS    =
#NGCGUI_OPTIONS   = opt1 opt2 ...
# opt items:
#   nonew      -- disallow making a new custom tab
#   noremove   -- disallow removing any tab page
#   noauto     -- no auto send (makeFile, then manually send)
#   noiframe   -- no internal image, image on separate top level

TTT               = truetype-tracer
TTT_PREAMBLE      = ../../nc_files/ngcgui_lib/utilitysubs/in_std.ngc

PROGRAM_PREFIX          = ../../nc_files
----

== Subroutine Requirements

An NGCGUI-compatible subfile contains a single subroutine definition. The name
of the subroutine must be the same as the filename (not including the .ngc
suffix). EMC2 supports named or numbered subroutines, but only named
subroutines are compatible with NGCGUI. For more information see the
<<cha:O-Codes,O-Codes>> Chapter.

The first non-comment line should be a sub statement.
The last non-comment line should be a endsub statement.

.examp.ngc:
----
o<examp> sub
  BODY_OF_SUBROUTINE
o<examp> endsub
----

The body of the subroutine should begin with a set of statements that define
local named parameters for each positional parameter expected for the
subroutine call. These definitions must be consecutive beginning with #1 and
ending with the last used parameter number. Definitions must be provided for
each of these parameters (no omissions).

.Parameter Numbering
----
#<xparm> = #1
#<yparm> = #2
#<zparm> = #3
----

EMC2 considers all numbered parameters in the range #1 thru #30 to be calling
parameters so ngcgui provides entry boxes for any occurence of parameters in
this range. It is good practice to avoid use of numbered parameters #1 through
#30 anywhere else in the subroutine. Using local, named parameters is
recommended for all internal variables.

Each defining statement may optionally include a special comment and a default
value for the parameter.

.Statement Prototype
----
#<vname> = #n (=default_value)
or
#<vname> = #n (comment_text)
or
#<vname> = #n (=default_value comment_text)
----

.Parameter Examples
----
#<xparm> = #1 (=0.0)
#<yparm> = #2 (Ystart)
#<zparm> = #3 (=0.0 Z start setting)
----

If a default_value is provided, it will be entered in the entry box
for the parameter on startup.

If comment_text is included, it will be used to identify the input
instead of the parameter name.

.Global Named Parameters
Notes on global named parameters (#<_globalname>) and ngcgui:

As in many programming languages, use of globals is powerful but can often lead
to unexpected consequences. In EMC2, existing global named parameters will be
valid at subroutine execution and subroutines can modify or create global named
parameters.

The use of global named parameters as inputs to subroutines is discouraged
because such usage requires the establishment and maintenance of a well-defined
global context that is problematic to maintain. Using numbered parameters #1
thru #30 as subroutine inputs should be sufficient to satisfy a wide range of
design requirements.

Ngcgui includes some support for global named input parameters but usage
is deprecated and not documented here.

While input global named parameters are discouraged, emc subroutines must use
global named parameters for returning results. Since ngcgui-compatible
subfiles are aimed at gui usage, return values are not a common requirement.
However, ngcgui is useful as a testing tool for subroutines which do return
global named parameters and it is common for ngcgui-compatible subfiles to call
utility subroutine files that return results with global named parameters.

To support these usages, ngcgui ignores global named parameters that include a
colon (Uśmiech character in their name. Use of the colon (Uśmiech in the name prevents
ngcgui from making entryboxes for these parameters.

.Global Named Parameters
----
o<examp> sub
...
#<_examp:result> = #5410       (return the current tool diameter)
...
o<helper> call [#<x1>] [#<x2>] (call a subroutine)
#<xresult> = #<_helper:answer> (localize immediately the helper result)
#<_helper:answer> = 0.0        (nullify global named parameter used by subroutine)
...
o<examp> endsub
----

In the above example, the utility subroutine will be found in a separate file
named helper.ngc. The helper routine returns a result in a global
named parameter named #<_helper:answer.

For good practice, the calling subfile immediately localizes the result for use
elsewhere in the subfile and the global named parameter used for returning the
result is nullified in an attempt to mitigate its inadvertent use elsewhere in
the global context. (A nullification value of 0.0 may not always be a good
choice).

Ngcgui supports the creation and concatenation of multiple features for a
subfile and for multiple subfiles. It is sometimes useful for subfiles to
determine their order at runtime so ngcgui inserts a special global parameter
that can be tested within subroutines. The parameter is named #<_feature:>.
Its value begins with a value of 0 and is incremented for each added feature.

.Additional Features
A special 'info' comment can be included anywhere in an ngcgui-compatible
subfile. The format is:

----
(info: info_text)
----

The info_text is displayed near the top of the ngcgui tab page in axis.

An optional image file (.png,.gif,.jpg,.pgm) can accompany a subfile. The
image file can help clarify the parameters used by the subfile. The image file
should be in the same directory as the subfile and have the same name with an
appropriate image suffix, e.g. the subfile examp.ngc could be accompanied by an
image file examp.png. Ngcgui attempts to resize large images by subsampling
to a size with maximum width of 320 and maximum height of 240 pixels.

None of the conventions required for making an ngcgui-compatible subfile
preclude its use as general purpose subroutine file for EMC2.

The EMC2 distribution includes a library (ngcgui_lib directory) that
includes both example ngcgui-compatible subfiles and utility files
to illustrate the features of EMC2 subroutines and ngcgui usage.

Additional user sumitted subroutines can be found on the Forum in the
Subroutines Section.

== DB25 Example

The following shows the DB25 subroutine. In the first photo you see where you
fill in the blanks for each variable.

image::images/ngcgui-db25-1.png[]

This photo shows the backplot of the DB25 subroutine.

image::images/ngcgui-db25-2.png[]

This photo shows the use of the new button and the custom tab to create
three DB25 cutouts in one program.

image::images/ngcgui-db25-3.png[]
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #2 : Styczeń 08, 2012, 07:36:16 »

2.2. Getting the source with git
 EMC2 source is stored in a system called Git. If you plan to make changes to emc2, it's highly recommended to use this method. With git, you can maintain your changes over time while getting bugfixes and new features. Git also makes it easy to submit your improvements to the linuxcnc.org team for inclusion in future versions of the software.

 First, follow the steps above to get the extra packages needed to compile emc.

 Before you can get a copy of EMC2 from our git server you will need to install the git program:
 sudo apt-get install git-core gitk git-gui

 Once you have installed git, you will use one of the following forms of the git clone command:
 git clone git://git.linuxcnc.org/git/emc2.git emc2-dev
 This puts the project in the directory 'emc2-dev'. To put the local copy of the project in a different location, just change the last argument of the 'git clone' command. Git will download about 37MB of data and it takes about 7 minutes to complete. You should only have to do this once.

 The commands below generally assume you are inside the emc2-dev directory.

 By default, you will get files from "master", which is the name for the branch where new feature development takes place. If you want to track another branch,
 git branch --track v2.4_branch origin/v2.4_branch
 git checkout v2.4_branch
 (For branches before v2.4_branch, use the form v2_3_branch instead)

 To get a particular version of emc, use
 git checkout vX.Y.Z
 For instance, to get released version 2.4.0, use
 git checkout v2.4.0

 Note that if you use an tag for a specific release, you will never get any updates since the tag specifies a particular snapshot of the files. Using a branch tag, such as "v2.4_branch", will continue to get changes as long as that branch is being developed.

Git has more instructions, such as how to update your version of emc2 after other developers have made improvements.
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #3 : Styczeń 08, 2012, 07:37:15 »

2.3. Getting the latest updates with git
 Assuming that you already have a checkout from git,
 git pull
 If you have made changes locally, then before doing this step you must "git commit" or "git stash" them. For more information, see Git.

2.4. Building emc2 (realtime)

If you have already installed EMC from the Live CD do not use --prefix/make install. Use the 'run in place' method (the default) instead.

 Run these commands in the directory created by git above (usually emc2-dev):
 $ cd src
 $ ./autogen.sh       
 $ ./configure
 $ make
 $ make install-menus
 $ sudo make setuid

 the make command may take several minutes to complete.

2.5. Building emc2 (simulator)
 Run these commands in the directory created by git above:
 $ cd src
 $ ./autogen.sh     
 $ ./configure --enable-simulator
 $ make
 $ make install-menus

 the make command may take several minutes to complete.

 Alternately, you can install a pre-compiled simulation-only version: download and execute http://linuxcnc.org/lucid/emc2-install-sim.sh (lucid lynx) or http://linuxcnc.org/hardy/emc2-install-sim.sh (hardy heron)

2.6. Building emc2 (with documents)
 Add "--enable-build-documentation" to the ./configure line, then "make". To build only HTML documentation, specify "--enable-build-documentation=html". To build only PDF documentation, specify "--enable-build-documentation=pdf".

 Building html documentation requires additional packages not installed by "apt-get build-dep emc2". Install them using the synaptic package manager.

2.7. Running emc2
 In the top directory that you placed the source, run
 $ . ./scripts/emc-environment
 $ emc
 and choose a configuration file from the list, or specify one on the command line:
 $ scripts/emc configs/sim/axis.ini
 If you get an error like
 Realtime system did not load
 then stop the rtai with
 $ halcmd unloadrt all
 $ halcmd stop
 then start again. Sometimes the first load will clear up an issue...
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #4 : Styczeń 08, 2012, 09:48:47 »

http://buildbot.linuxcnc.org/

tutaj są repozytoria
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #5 : Styczeń 08, 2012, 09:49:15 »

http://www.cnc.info.pl/topics54/pomyslowo-skonfigurowany-emc-vt33084,10.htm
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #6 : Styczeń 12, 2012, 08:30:30 »

czasami coś nie do końca zostało zinternacjonalizowane w ngcgui Smutny
np. przycisk Finalize nie dawał się podmieniać na wybrany tekst po polsku (Przekaż)

w linii 1196 (ngcgui.tcl):
Kod:
if $::ngc($hdl,auto) {set text Finalize}

trzeba dodać elementy pozwalające internacjonalizować przycisk Finalize
Kod:
if $::ngc($hdl,auto) {set text "[_ "Finalize"]"}

czyli otoczyć tekst Finalize tak aby internacjonalizatro to mógł zobaczyć Uśmiech

jest jeszcze parę miejsc do uzdatnienia...
« Ostatnia zmiana: Styczeń 12, 2012, 09:16:36 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #7 : Styczeń 12, 2012, 09:18:29 »

Początek - definiujący sposób internacjonalizacji

"_" zastępuje ::msgcat::mc

#-----------------------------------------------------------------------
# Internationalization

# use the tcl-package named Emc to set up I18n support
if [catch {package require Emc} msg] {
  # if user is trying to use as standalone in an unconfigured (non-Emc)
  # environment, just continue without internationalization
  puts stderr "Internationalization not available: <$msg>"
}
# use a command or proc named "_" for ::msgcat::mc
# when embedded in axis, a command named "_" is predefined,
# since "_" is not defined for standalone usage, make a proc named "_"
if {"" == [info command "_"]} {
  package require msgcat
  proc _ {s} {return [::msgcat::mc $s]}
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #8 : Styczeń 12, 2012, 09:26:39 »

Tcl po polsku! [Rozszerzenia]

Dostarczane razem z rdzeniem Tcl


Swego rodzaju rozszerzeniem jest Tk, tyle że nie koniecznie musi być rozprowadzane z rdzeniem Tcl (np na serwerach - tam nie ma X'ów).

Używając jedynie Tcl (tclsh) możemy śmiało używać 2 rozszerzeń:
  • msgcat (pozwala na łatwą implementację obsługi wielu języków dla naszej aplikacji)
  • http (obsługa protokołu http)
W Tk, w wersji 8.5 ma wejść do standardu rozszerzenie Tile (o tym niżej).

Oto typowy przykład wykorzystania paczki http:

package require http
http::config -useragent "Mozilla"

set query "http://www.google.com/search?btnI=&q=Tcl"
catch {set token [http::geturl $query]}
upvar #0 $token state
foreach {name value} $state(meta) {
    if {[regexp -nocase ^location$ $name]} {
        set newurl [string trim $value]
        puts "Znaleziono: $newurl"
    }
}

Wykonanie tego kodu powinno wyświetlić nam: Znaleziono: http://www.tcl.tk
no chyba że ta strona już spadła z 1 miejsca w rankingu google, kiedy czytasz ten tekst :)

Pierwsza linia jest chyba jasna, prawda? Tak - [package require] służy do ładowania rozszerzeń. [http::config -useragent] ustawia łańcuch, jakim ma się przedstawiać nasz skrypt dla serwera www. Ustawienie "Mozilla" jest optymalne, bo każdy serwer www przepuści takiego klienta (jakie dziwaczne nazwy bywają blokowane przez serwery www). W czwartej linii ustawiamy zapytanie - dokładnie to co wpisuje się w pasku adresu przeglądarki www - widać, że q=Tcl jest zapytaniem o "Tcl" w googlach. [catch] dla wyrażenia [http::geturl] jest niezbędne, bo wyrażenie to może zwrócić błąd - np gdy zadana strona nie istnieje. Kolejna linia (z [upvar]) wynika ze specyfiki działania paczki http. Powinno się ją wykonywać, ponieważ zmienna 'token' zawiera w sobie nazwię zmiennej, w której to dopiero znajdują się konkretne informacje. Zmienna przetrzymywana w 'token' jest tablicą, stąd później używamy '$state' jak tablicy. Pętla [foreach] pobiera elementy z wartości tablicy 'state' dla indektu 'meta' parami i dla pierwszego elementu sprawdza prawdziwość wyrażenia regularnego (patrz dokumentacja Tcl -> re_syntax), jeśli jest ono spełnione (czyli pierwszy element zawiera wyraz 'location') to drugi wyraz jest wtedy naszą szukaną stroną i ją wyświetlamy. Skąd wiedziałem że akurat muszę parami szukać wyrażenia 'loaction' i że wtedy drugie jest naszą stroną? Po prostu - na początku użyłem skryptu zawierającego jedynie 6 pierwszych linii i wyświetliłem sobie za pomocą [puts] zawartość wszystkich elementów tablicy 'state', przeanalizowałem i napisałem mechanizm opracowujący to ładnie :)

Co do msgcat, to jest on bardzo podobny do wielu innych systemów lokalizacji aplikacji. Interesuje nas kilka komend:
  • msgcat::mcset
  • msgcat::mc
  • msgcat::mcload
  • msgcat::mclocale

[mcset] służy do przyporządkowania orginalnemu (zazwyczaj angielskiemu) łańcuchowi odpowiednika w innym języku - dla nas Polskim. Składnia jest banalnie prosta:
msgcat::mcset język łańcuch-źródłowy łańcuch-przetłumaczony
czyli aby powiedzieć interpreterowi, że dla lokalizacji ustawionej na 'pl' łańcuch "This is a string" ma być przetłumaczony na "To jest łańcuch" wystarczy:

package require msgcat
msgcat::mcset pl "This is a string" "To jest łańcuch"

[mc] służy do używania zadeklarowanych łańcuchów do tłumaczenia. Zamiast pisać:

puts "This is a string"

napiszemy:

puts [msgcat::mc "This is a string"]

i wtedy ten łańcuch będzie przez polaka widziany po polsku (o ile będzie miał poprawnie ustawione lokale), a przez innych po angielsku.
A jak się sprawa ma ze zmiennymi argumentami w łańcuchach? Rozważmy przypadek:

set var 5
puts "Value of variable 'var' is: $var"
Spróbujmy zastosować msgcat:

package require msgcat
msgcat::mcset pl "Value of variable 'var' is: $var" "Wartość zmiennej 'var' to: $var"
set var 5
puts [msgcat::mc "Value of variable 'var' is: $var"]

W tym przypadku Tcl zwróci błąd, mówiąc że zmienna 'var' nie istnieje (chciał ją podstawić przy wywoływaniu [mcset], ponieważ użyłem cudzysłowia). No to użyjmy nawiasów klamrowych:

package require msgcat
msgcat::mcset pl {Value of variable 'var' is: $var} {Wartość zmiennej 'var' to: $var}
set var 5
puts [msgcat::mc "Value of variable 'var' is: $var"]

Tym razem [mcset] nie wywoła błędu, ale niestety tekst nie zostanie przetłumaczony. Dlaczego? Otóż wywołanie [mc] w [puts] przyjmuje łańcuch ze zmienną, którą najpierw podstawia i dopiero wtedy próbuje tłumaczyć, no a nie ma przecież do przetłumaczenia łańcucha "Value of variable 'var' is: 5", prawda? Dlatego używa się specjalnego wyrażenia w łańcuchach tłumaczonych - '%s', w ten sposób:

package require msgcat
msgcat::mcset pl "Value of variable 'var' is: %s" "Wartość zmiennej 'var' to: %s"
set var 5
puts [msgcat::mc "Value of variable 'var' is: %s" $var]

I teraz [mc] wie jaki łańcuch ma przetłumaczyć - nic się w nim nie zmienia. Najpierw tłumaczy łańcuch, a następnie wszystkie za wystąpienia %s podstawia kolejne argumenty występujące po łańcuchu do tłumaczenia. Można używać innych wyrażeń niż %s - wszystkich obsługiwanych przez komendę [format], ale '%s' jest po prostu uniwersalnym.

[mcload] służy do ładowania tłumaczeń z gotowych plików zawierających tłumaczenia. Jako argument podaje się ścieżkę do katalogu z plikami tłumaczeń. Pliki te muszą mieć postać język.msg, gdzie człon 'język' jest identyfikatorem języka, jak 'pl', czy 'en'. Pliki tłumaczeń powinny być tworzone w kodowaniu UTF-8.

[mclocale] służy do ustawiania lokalizacji ręcznie, jeśli z jakiegoś powodu msgcat, nie potrafił odczytać jej z systemu.

Można posłużyć się [namespace import] w celu skrócenia użycia komend z rozszerzenia. Jeśli nie mamy w swoim skrypcie procedur o takich samych nazwach jak te z rozszerzenia to możemy śmiało wpisać:

package require msgcat
namespace import msgcat::*

i dzięki temu teraz zapis wcześniejszego przykładu wygląda teraz tak:

mcset pl "Value of variable 'var' is: %s" "Wartość zmiennej 'var' to: %s"
set var 5
puts [mc "Value of variable 'var' is: %s" $var]

Tile jest odpowiedzią na nagminne narzekania programistów i użytkowników, którzy krytykowali staromodny wygląd Tk, wzorowany na Motifie, niegodny używania w XXI wieku. Tile wprowadza do Tk system "skórek", dzięki czemu wygląd Tk zależy już jedynie od wyobraźni programistów/grafików. Możliwe jest używanie skórek opartych o obrazki obsługiwane przez Tk (czyli domyślnie GIF, a w połączeniu z rozszerzeniem Img - także innych), a także gotowych "silników" renderowania wyglądu - jest kilka gotowych, wchodzących skład Tile, a od jakiegoś czasu trwają prace nad przeportowaniem kontrolek Qt dla Tile. Jednym zdaniem: Tile jest tym, czego Tk brakowało od jakiegoś czasu, aby ten pełen zalet ToolKit nie miał wad ;)

Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #9 : Styczeń 12, 2012, 10:48:09 »

następny tekst nie-i18n - linia 962 w ngcgui.tcl:
Kod:
   set ay($hdl,info)               "Choose Files"

powinno być:
Kod:
  set ay($hdl,info)               "[_ "Choose Files"]"
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #10 : Styczeń 16, 2012, 12:17:10 »

skompilowane komunikaty
http://markcomp77.p9.pl/img/ngcgui/po/emc2.mo

wersja źródłowa komunikatów
http://markcomp77.p9.pl/img/ngcgui/po/pl.po
« Ostatnia zmiana: Styczeń 16, 2012, 03:46:04 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp77
dużo wiedzący
**
Offline Offline

Wiadomości: 17


« Odpowiedz #11 : Styczeń 16, 2012, 12:26:02 »

/usr/share/locale/pl/LC_MESSAGES

tutaj podmienić plik emc2.mo
Zapisane

 poważaniem
MARK mark@2a.pl; +48-602-346070; GG:1526904
markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #12 : Styczeń 16, 2012, 12:32:54 »

konfiguracje (do katalogu ~/emc2/configs)
http://markcomp77.p9.pl/img/ngcgui/po/_configs.tar.bz2
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #13 : Styczeń 16, 2012, 03:48:17 »

opis procedury dodania polskich komunikatów do NGCGUI



wrzucam to co mam dotyczące tłumaczenia...

-------------------------------------------------------
przygotowane tak aby można było zrobić wstawić do wersji binarnej emc2-2.6

położenie plików sprawdzone na realnej maszynie działającej na ubuntu-emc 10.04 (iso z linuxcnc.org) z upgradem do emc2-2.6

podmiana repozytoriów w pliku /etc/apt/sources.list na:
Kod:
deb     http://buildbot.linuxcnc.org/ lucid master-rt
i potem
Kod:
sudo apt-get update
sudo apt-get upgrade

i mamy emc2 - 2.6 (rozwojowe)



----------zmiana 1) w skrypcie: w linii 1196 (ngcgui.tcl):

Kod:
if $::ngc($hdl,auto) {set text Finalize}

trzeba dodać elementy pozwalające internacjonalizować przycisk Finalize
Kod:
if $::ngc($hdl,auto) {set text "[_ "Finalize"]"}

----------zmiana 2) w skrypcie: tekst nie-i18n - linia 962 w ngcgui.tcl:
Kod:
   set ay($hdl,info)               "Choose Files"

powinno być:
Kod:
  set ay($hdl,info)               "[_ "Choose Files"]"


-----------pliki tłumaczeń
postać źródłowa:
http://markcomp77.p9.pl/img/ngcgui/po/pl.po

skompilowane, zastąpić to co jest w: /usr/share/locale/pl/LC_MESSAGES
http://markcomp77.p9.pl/img/ngcgui/po/emc2.mo

----------konfiguracja na ngcgui... trochę spolszczone
konfiguracje (rozpakować do katalogu ~/emc2/configs)
http://markcomp77.p9.pl/img/ngcgui/po/_configs.tar.bz2
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #14 : Styczeń 18, 2012, 11:13:05 »

zmiana linii 1699 w ngcgui.tcl

Kod:
lappend err "[_ "Missing value for parm"] #$i ($token)"
« Ostatnia zmiana: Styczeń 18, 2012, 11:28:56 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #15 : Styczeń 18, 2012, 11:30:12 »

linia 1688 ngcgui.tcl

Kod:
lappend err "No Subfile sp1ecified"

zamiana na
Kod:
lappend err "[_ "No Subfile sp1ecified"]"[/code[
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #16 : Styczeń 18, 2012, 11:33:40 »

linia 1690:
Kod:
lappend err "[_ "No parameters yet"]"
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #17 : Styczeń 18, 2012, 11:57:29 »

linia 1294:

Kod:
-title "$::ngc(any,app) [_ "Preamble file"]" \
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #18 : Styczeń 18, 2012, 12:01:31 »

linia 1423

Kod:
-title "$::ngc(any,app) [_ "Subroutine file"]" \

Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #19 : Styczeń 18, 2012, 12:04:00 »

linia 1374
Kod:
-title "$::ngc(any,app) [_ "Postamble file"]" \
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #20 : Styczeń 18, 2012, 02:04:12 »

problem z i18n Smutny
interp_o_word.cc

linia 840:
Kod:
    case O_if:
if (control_find_oword(block, settings, &op) == INTERP_OK) {
    if (settings->sequence_number != (op->sequence_number + 1))
        OERR(_("%d: duplicate O-word label - already defined in line %d: '%s'"),
    settings->sequence_number, op->sequence_number + 1,
    settings->linetext);
} else
    CHP(control_save_offset(block, settings));

podobne..
linia 786
Kod:
case O_while:
if (control_find_oword(block, settings, &op) == INTERP_OK) {
    if ((op->type != O_do) &&
(settings->sequence_number != (op->sequence_number + 1)))
        OERR(_("%d: duplicate O-word label: '%s' - defined in line %d"),
    settings->sequence_number,
    settings->linetext, op->sequence_number + 1);
} else


linia 736:
Kod:
    case O_repeat:
if (control_find_oword(block, settings, &op) == INTERP_OK) {
    if (settings->sequence_number != (op->sequence_number + 1))
        OERR(_("%d: duplicate O-word label: '%s' - defined in line %d"),
    settings->sequence_number,
    settings->linetext, op->sequence_number + 1);
} else


nie reaguje na internacjonalizację w pliku pl.po... Smutny

Kod:
#: emc/rs274ngc/interp_o_word.cc:738 emc/rs274ngc/interp_o_word.cc:788
#, c-format
msgid  "%d: duplicate O-word label: '%s' - defined in line %d"
msgstr "%d: powtórzona etykata O-word: '%s' - w linii %d"

#: emc/rs274ngc/interp_o_word.cc:843
#, c-format
msgid  "%d: duplicate O-word label - already defined in line %d: '%s'"
msgstr "%d: powtórzona etykata O-word w linii %d: \"%s\""
« Ostatnia zmiana: Styczeń 18, 2012, 02:06:33 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 14874



WWW
« Odpowiedz #21 : Styczeń 18, 2012, 02:14:34 »

oraz aktualizacja:
http://markcomp77.p9.pl/img/ngcgui/po/pl.po
http://markcomp77.p9.pl/img/ngcgui/po/emc2.mo
 i aby.. ułatwić
http://markcomp77.p9.pl/img/ngcgui/po/ngcgui.tcl z bieżącymi modyfikacjami i18n
Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

Strony: [1]   Do góry
  Drukuj  
 
Skocz do:  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Manuscript design by Bloc Strona wygenerowana w 0.082 sekund z 19 zapytaniami.