%%
%% This is file `pst-osci.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-osci.tex'
%%
%% Authors  : Manuel LUQUE <Mluque5130@aol.com>
%%            Christophe JORSSEN <Christophe.Jorssen@free.fr>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-osci' is a PSTricks package to plot oscilloscope diagrams
%%
%% AllColor=false (true par défaut) Raoul HATTERER<Hatterer.Raoul@wanadoo.fr>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\csname PSTOscilloLoaded\endcsname
\let\PSTOscilloLoaded\endinput
%
% Require PSTricks, pstcol,pstplot and multido packages
\ifx\PSTplotLoaded\endinput\else\input pst-plot.tex\fi
\ifx\MultidoLoaded\endinput\else\input multido.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi % hv

\def\fileversion{2.82}% modifié
\def\filedate{2005/10/17}

\message{`PST-osci' v\fileversion, \filedate\space (ML/CJ)}
%%Last mod. by : Raoul HATTERER 2003/11/02
%%Last mod. by : Herbert Voss 2005/11/07
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\pst@addfams{pst-osci}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\font\ssf=cmss10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newrgbcolor{Beige}{0.96 0.96 0.86}
\newrgbcolor{LightGray}{0.8 0.8 0.8}
\newrgbcolor{VeryLightGray}{0.9 0.9 0.9}
\newcmykcolor{PaleOrange}{0 0.2 0.4 0}
\newcmykcolor{LightBlue}{0.1 0 0 0}
\newrgbcolor{ACredA}{1 0 0}
\newrgbcolor{ACgreenA}{0 1 0}
\newrgbcolor{ACmagentaA}{1 0 1}
\newrgbcolor{ACred}{0 0 0}
\newrgbcolor{ACgreen}{.25 .25 .25}% green or Darkgray
\newrgbcolor{ACmagenta}{0 0 0}% magenta or black
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\define@key[psset]{pst-osci}{period1}{\edef\psk@Oscillo@PeriodA{#1}}
\define@key[psset]{pst-osci}{period2}{\edef\psk@Oscillo@PeriodB{#1}}
\define@key[psset]{pst-osci}{periodmodulation1}{\edef\psk@Oscillo@PeriodModulationA{#1}}
\define@key[psset]{pst-osci}{freqmod1}{\edef\psk@Oscillo@FreqModA{#1}}
\define@key[psset]{pst-osci}{periodmodulation2}{\edef\psk@Oscillo@PeriodModulationB{#1}}
\define@key[psset]{pst-osci}{freqmod2}{\edef\psk@Oscillo@FreqModB{#1}}
\define@key[psset]{pst-osci}{amplitude1}{\edef\psk@Oscillo@AmplitudeA{#1}}
\define@key[psset]{pst-osci}{amplitude2}{\edef\psk@Oscillo@AmplitudeB{#1}}
\define@key[psset]{pst-osci}{CC1}{\edef\psk@Oscillo@ContinuousComponentA{#1}}
\define@key[psset]{pst-osci}{CC2}{\edef\psk@Oscillo@ContinuousComponentB{#1}}
\define@key[psset]{pst-osci}{timediv}{\edef\psk@Oscillo@TimeDiv{#1}}
\define@key[psset]{pst-osci}{phase1}{\edef\psk@Oscillo@PhaseA{#1}}
\define@key[psset]{pst-osci}{phase2}{\edef\psk@Oscillo@PhaseB{#1}}
\define@key[psset]{pst-osci}{sensivity1}{\edef\psk@ChannelA{#1}}
\define@key[psset]{pst-osci}{sensivity2}{\edef\psk@ChannelB{#1}}
\define@key[psset]{pst-osci}{damping1}{\edef\psk@Oscillo@dampingA{#1}}
\define@key[psset]{pst-osci}{damping2}{\edef\psk@Oscillo@dampingB{#1}}
\define@key[psset]{pst-osci}{Fourier}{\edef\psk@Oscillo@Fourier{#1}}
\define@key[psset]{pst-osci}{offset1}{\edef\psk@Oscillo@OffsetA{#1}}
\define@key[psset]{pst-osci}{offset2}{\edef\psk@Oscillo@OffsetB{#1}}
\define@key[psset]{pst-osci}{offset3}{\edef\psk@Oscillo@OffsetC{#1}}
\define@key[psset]{pst-osci}{plotstyle1}{\edef\psk@Oscillo@PlotStyleA{#1}}
\define@key[psset]{pst-osci}{plotstyle2}{\edef\psk@Oscillo@PlotStyleB{#1}}
\define@key[psset]{pst-osci}{plotstyle3}{\edef\psk@Oscillo@PlotStyleC{#1}}
\define@key[psset]{pst-osci}{plotstyle4}{\edef\psk@Oscillo@PlotStyleD{#1}}
\define@key[psset]{pst-osci}{operation}{%
  \def\@tempa{#1}%
  \let\psk@Oscillo@Operation\@tempa}
\define@key[psset]{pst-osci}{Wave1}{%
  \def\@tempa{#1}%
  \let\psk@Oscillo@WaveA\@tempa}
\define@key[psset]{pst-osci}{Wave2}{%
  \def\@tempa{#1}%
  \let\psk@Oscillo@WaveB\@tempa}
\newif\ifPst@Oscillo@Lissajous
\define@key[psset]{pst-osci}{Lissajous}[true]{\@nameuse{Pst@Oscillo@Lissajous#1}}
\newif\ifPst@Oscillo@AllColor
\define@key[psset]{pst-osci}{AllColor}[true]{\@nameuse{Pst@Oscillo@AllColor#1}}
\newif\ifPst@Oscillo@Combine
\define@key[psset]{pst-osci}{combine}[true]{\@nameuse{Pst@Oscillo@Combine#1}}
%
\psset{period1=20,period2=20,amplitude1=2,amplitude2=0,%
  phase1=0,phase2=0,timediv=5,Lissajous=false,AllColor=true,sensivity1=1,%
  sensivity2=1,damping1=0,damping2=0,combine=false,%
  offset1=0,offset2=0,plotstyle1=GreenContA,Fourier=100,%
  plotstyle2=BlueContB,plotstyle3=RedContLissajou,%
  plotstyle4=MagentaContAddSub,operation=\relax,Wave1=\SinusA,Wave2=\SinusB,%
  periodmodulation1=100,freqmod1=0,periodmodulation2=100,%
  freqmod2=0,CC1=0,CC2=0,offset3=0}
%
\newpsstyle{GreenContA}{linecolor=green,linewidth=0.05,plotpoints=360}
\newpsstyle{BlackContA}{linecolor=black,%AllColor
  linewidth=0.05,plotpoints=360}
\newpsstyle{BlueContB}{linecolor=blue,linewidth=0.05,plotpoints=360}
\newgray{darkgray}{.25}
\newpsstyle{DarkgrayContB}{linecolor=darkgray,%AllColor
  linewidth=0.06,plotpoints=360}
\newpsstyle{RedContLissajou}{linecolor=red,linewidth=0.05,plotpoints=1000}
\newpsstyle{BlackContLissajou}{linecolor=black,%AllColor
  linewidth=0.06,plotpoints=1000}
\newpsstyle{MagentaContAddSub}{linecolor=magenta,linewidth=0.05,plotpoints=1000}
\newgray{gray}{.5}
\newpsstyle{DarkgrayDashAddSub}{linestyle=dashed,linecolor=darkgray,%AllColor
  linewidth=0.06,plotpoints=1000}

\def\TriangleA{%
/Cste 0.4050284 def % 4/pi^2
/A1 \psk@Oscillo@AmplitudeA\space 2 mul def % Amplitude peak to peak
0 1 2 fourier{
/n exch def
t 10 mul T1 div BT mul
n mul cos
n n mul div  Cste mul A1 mul add
}for  e t AR1 mul neg exp mul SA div CC1 add}

\def\TriangleB{%
/Cste 0.4050284 def % 4/pi^2
/A2 \psk@Oscillo@AmplitudeB\space 2 mul def
0 1 2 fourier{
/n exch def
t 10 mul T2 div BT mul
n mul cos
n n mul div  Cste mul A2 mul add
}for e t AR2 mul neg exp mul SB div CC2 add}

\def\RectangleA{
/Cste 0.6366 def
/A1 \psk@Oscillo@AmplitudeA\space 2 mul def
0 1 2 fourier{ %
/n exch def
t 10 mul T1 div BT mul
n mul sin
n div Cste mul A1 mul add %
}for
e t AR1 mul neg exp mul SA div CC1 add}

\def\RectangleB{
/Cste 0.6366 def
/A2 \psk@Oscillo@AmplitudeB\space 2 mul def
0 1 2 fourier{ %
/n exch def
t 10 mul T2 div BT mul
n mul sin
n div Cste mul A2 mul add %
}for
e t AR2 mul neg exp mul SB div CC2 add}

\def\RDogToothA{
/Cste 0.6366 def /timediv 5 def
0 1 1 fourier{ %
/n exch def
t 10 mul T1 div BT mul
n mul sin
n div -1 1 n add exp mul Cste mul A1 mul add%
}for
e t AR1 mul neg exp mul SA div CC1 add}

\def\RDogToothB{
/Cste 0.6366 def /timediv 5 def
0 1 1 fourier{%
/n exch def
t 10 mul T2 div BT mul
n mul sin
n  div -1 1  n add exp mul Cste mul A2 mul add%
}for
SB div CC2 add}

\def\LDogToothA{
/Cste 0.6366 def /timediv 5 def t
0 1 1 fourier{%
/n exch def
t 10 mul T1 div BT mul
n mul sin
n  div 180 n mul cos mul Cste mul A1 mul add%
}for
e t AR1 mul neg exp mul SA div CC1 add}

\def\LDogToothB{
/Cste 0.6366 def /timediv 5 def
0 1 1 fourier{%
/n exch def
t 10 mul T2 div BT mul
n mul sin
n div 180 n mul cos mul Cste mul A2 mul add%
}for
e t AR2 mul neg exp mul SB div CC2 add}

\def\SinusA{%
t 10 mul T1 div BT mul
mod1 57.3 mul t 10 mul Tm1 div BT mul sin mul add
phaseA add sin A1 mul
e t AR1 mul neg exp mul SA div CC1 add}

\def\SinusB{%
t 10 mul T2 div BT mul
mod2 57.3 mul t 10 mul Tm2 div BT mul sin mul
add phaseB add sin A2 mul
e t AR2 mul neg exp mul SB div CC2 add}

\def\Oscillo{\@ifnextchar[\Oscillo@i{\Oscillo@i[]}}
\def\Oscillo@i[#1]{%
  \begingroup
  \def\pst@par{#1}\ifx\pst@par\@empty\else\psset{#1}\fi
  \pst@killglue
  \ifPst@Oscillo@AllColor
    \psset{plotstyle1=GreenContA,plotstyle2=BlueContB,%
     plotstyle3=RedContLissajou,plotstyle4=MagentaContAddSub}
  \else
    \psset{plotstyle1=BlackContA,plotstyle2=DarkgrayContB,%
     plotstyle3=BlackContLissajou,plotstyle4=DarkgrayDashAddSub}
  \fi
  \ifx\pst@par\@empty\else\psset{#1}\fi
  \pspicture(0,-5)(10,5) 
    \psframe*[linecolor=LightBlue](0,-4)(10,4)
    \psgrid[gridlabels=0,subgriddiv=0](0,-4)(10,4)
    \multido{\nxDiv=0+0.2}{50}{%
      \psline(\nxDiv,-.1)(\nxDiv,0.1)}
    \multido{\nyDiv=-4.0+0.2}{40}{%
      \psline(4.9,\nyDiv)(5.1,\nyDiv)}
    \psframe[fillcolor=VeryLightGray,fillstyle=solid,dimen=middle](0,4)(10,5)
    \rput(1.5,4.8){\ssf timeDiv :} \rput(1.5,4.3){\ssf\psk@Oscillo@TimeDiv{}ms/div}
    \rput(4,4.8){\ssf Channel A :} \rput(4,4.3){\ssf\psk@ChannelA{} V/div}
    \rput(7,4.8){\ssf Channel B :} \rput(7,4.3){\ssf\psk@ChannelB{} V/div}
    \rput(9,4.8){\ssf XY}  
    \rput(9,4.3){\ifPst@Oscillo@Lissajous
      \ifPst@Oscillo@AllColor\ACredA\else\ACred\fi ON
      \else\ifPst@Oscillo@AllColor\ACgreenA\else\ACgreen\fi OFF\fi}%AllColor
    \psframe[fillcolor=VeryLightGray,fillstyle=solid,dimen=middle](0,-5)(10,-4)
    \ifPst@Oscillo@Combine
      \rput(2,-4.3){\ssf\psk@Oscillo@Operation:}
      \rput(2,-4.8){\ssf\ifPst@Oscillo@AllColor\ACmagentaA\else\ACmagenta\fi ON}%AllColor
    \fi
    \rput(6.5,-4.3){\ssf OffsetB}
    \rput(6.5,-4.8){\ssf \psk@Oscillo@OffsetB}
    \rput(8.5,-4.3){\ssf OffsetC}
    \rput(8.5,-4.8){\ssf \psk@Oscillo@OffsetC}
    \rput(4.5,-4.3){\ssf OffsetA}
    \rput(4.5,-4.8){\ssf \psk@Oscillo@OffsetA}
    \ifPst@Oscillo@Lissajous
      \psclip{\psframe(0,-4)(10,4)}
      \parametricplot[style=\psk@Oscillo@PlotStyleC]{0}{360}{%
        /fourier \psk@Oscillo@Fourier\space def
        /T1 \psk@Oscillo@PeriodA\space def
        /T2 \psk@Oscillo@PeriodB\space def
        /Tm1 \psk@Oscillo@PeriodModulationA\space def
        /mod1 \psk@Oscillo@FreqModA\space def
        /Tm2 \psk@Oscillo@PeriodModulationB\space def
        /mod2 \psk@Oscillo@FreqModB\space def
        /CC1 \psk@Oscillo@ContinuousComponentA\space def
        /CC2 \psk@Oscillo@ContinuousComponentB\space def
        /BT T1 def
        /A1 \psk@Oscillo@AmplitudeA\space def
        /A2 \psk@Oscillo@AmplitudeB\space def
        /phaseA \psk@Oscillo@PhaseA\space def
        /phaseB \psk@Oscillo@PhaseB\space def
        %/K 36 T div def
        /e 2.718 def
        /AR1 \psk@Oscillo@dampingA\space def
        /AR2 \psk@Oscillo@dampingB\space def
        /SA \psk@ChannelA\space def
        /SB \psk@ChannelB\space def
        /offset1 \psk@Oscillo@OffsetA\space def
        /offset2 \psk@Oscillo@OffsetB\space def
        \psk@Oscillo@WaveA\space 5 add
        \psk@Oscillo@WaveB\space}
      \endpsclip
    \else
      \psclip{\psframe(0,-4)(10,4)}\psset{xunit=0.02777}
        \parametricplot[style=\psk@Oscillo@PlotStyleA]{0}{360}{%
          /fourier \psk@Oscillo@Fourier\space def
          /T1 \psk@Oscillo@PeriodA\space def
          /Tm1 \psk@Oscillo@PeriodModulationA\space def
          /mod1 \psk@Oscillo@FreqModA\space def
          /BT \psk@Oscillo@TimeDiv\space def
          /A1 \psk@Oscillo@AmplitudeA\space def
          /phaseA \psk@Oscillo@PhaseA\space def
          /CC1 \psk@Oscillo@ContinuousComponentA\space def
          /e 2.718 def
          /AR1 \psk@Oscillo@dampingA\space def
          /offset1 \psk@Oscillo@OffsetA\space def
          /SA \psk@ChannelA\space def
          t \psk@Oscillo@WaveA\space
          offset1 add
        }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\parametricplot[style=\psk@Oscillo@PlotStyleB]{0}{360}{%
/fourier \psk@Oscillo@Fourier\space def
/T2 \psk@Oscillo@PeriodB\space def
/Tm2 \psk@Oscillo@PeriodModulationB\space def
/mod2 \psk@Oscillo@FreqModB\space def
/BT \psk@Oscillo@TimeDiv\space def
/A2 \psk@Oscillo@AmplitudeB\space def
/phaseB \psk@Oscillo@PhaseB\space def
/CC2 \psk@Oscillo@ContinuousComponentB\space def
/e 2.718 def
/AR2 \psk@Oscillo@dampingB\space def
/offset2 \psk@Oscillo@OffsetB\space def
/SB \psk@ChannelB\space def
t \psk@Oscillo@WaveB\space
offset2 add
}
\ifPst@Oscillo@Combine
%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\parametricplot[style=\psk@Oscillo@PlotStyleD]{0}{360}{%
/fourier \psk@Oscillo@Fourier\space def
/T1 \psk@Oscillo@PeriodA\space def
/T2 \psk@Oscillo@PeriodB\space def
/Tm1 \psk@Oscillo@PeriodModulationA\space def
/mod1 \psk@Oscillo@FreqModA\space def
/Tm2 \psk@Oscillo@PeriodModulationB\space def
/mod2 \psk@Oscillo@FreqModB\space def
/BT \psk@Oscillo@TimeDiv\space def
/A1 \psk@Oscillo@AmplitudeA\space def
/A2 \psk@Oscillo@AmplitudeB\space def
/phaseA \psk@Oscillo@PhaseA\space def
/phaseB \psk@Oscillo@PhaseB\space def
/CC1 \psk@Oscillo@ContinuousComponentA\space def
/CC2 \psk@Oscillo@ContinuousComponentB\space def
/offset3 \psk@Oscillo@OffsetC\space def
/e 2.718 def
/AR1 \psk@Oscillo@dampingA\space def
/AR2 \psk@Oscillo@dampingB\space def
/SA \psk@ChannelA\space def
/SB \psk@ChannelB\space def
/offset1 \psk@Oscillo@OffsetA\space def
/offset2 \psk@Oscillo@OffsetB\space def
t \psk@Oscillo@WaveA\space
\psk@Oscillo@WaveB\space
\psk@Oscillo@Operation%
\space offset3 add}
\fi
\endpsclip\fi
\endpspicture%
\endgroup\ignorespaces}
\catcode`\@=\PstAtCode\relax
\endinput
