Allow Selected State At checkout Page

In magento In Checkout We have to allow Some specific State For That you need to customize, extend Magento functionality.

For extend this functionality you have to Make plugin To avoid conflicts in future for Upgradation of Magento 2.

If you don’t Know How to make Plugin Visit Here

After creating a Custom Module You have to Extend Function of Vendor by Plugin Method.

Create a di.xml file In Your Module  Panchal/Module/etc/di.xml

 <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Customer\Controller\Account\Create" type="Panchal\Preference\Controller\Account\Create" /> </config> 

BER (Bit Error Rate) Calculation At different Angle in Indoor VLC

In Previous Post, we discussed How to calculate SNR for Indoor VLC Check Here

Now Using SNR we can calculate BER(Bit Error Rate )for Indoor VLC system. Normally BER rate would be 10-3 is Great in every communication system. Indoor VLC system gives BER in Range of 10-2 to 10-6. Indoor VLC is Give result variation at Angle of Tx (Transmitter) and Rx(Receiver), In another word we can be called it’s LOS(Line of Sight).  Indoor VLC give accurate Result on -45 To 45 Angle. In that Range, We can get average 10-5 BER.

BER depends on the modulation scheme and SNR of the system. Where Q is a function that depends upon the modulation scheme which used.

BER = Q√SNR

We have implemented the VLC channel in MATLAB. Now irradiance angle and incidence angle depend on the receiver’s position in the room. At different incidence angles and irradiance angles, we have measure SNR and BER. It is measured for the transmitter and receiver are in-line, we get maximum SNR and low BER. Performance graphs of SNR and BER are shown in Fig, 1 and Fig, 2 respectively.
SNR_FOV_VLC
BER_FOV_VLC
As discuss above FOV affect the performance of VLC system. For different transmitter’s FOV we can calculate SNR. Assume that the receiver is in the line of a transmitter. Transmitter’s FOV versus SNR graph is shown in Fig, 5As shown in the graph, to achieve high SNR, the transmitter’s FOV should be set above 50. One another important point is maximum SNR is achieved at FOV equal to 90.

For analyze VLC system performance, we assume some parameter for a room, LED, receiver and noise. That parameter listed in below Table, 1 [8] [2] [1].

VLC Ideal Parameter
Type Parameter Value
Transmitter Number of Transmitters (LED) 1
Power Radiated by LED 1W
Angle of Irradiance 70
Field of View (FOV) 70
LED location in Room [2,2,2]
Room & Other Size of Room [W x L x H] [4 x 4 x 2] m
Noise Current 0.562 Amp
Amplifier Bandwidth Factor 50e6
Ambient Light Power 5e-12 Amp
Data Rate 1e6 b/s
Distance Between Tx and Rx 1m
Filter Coefficient 1
Electron Charge 1.6e-19
Receiver Photodector Area 1e-4 cm2
Angle of Irradiance 70
Field of View (FOV) 90
Responsivity 1 A/W
Photodector Concentrator Refractive Index 1.46

 

 

CONCLUSION :

In Single Input Single Output (SISO) VLC system we get High SNR and low BER for LOS transmitter and receiver’s positions. So, Irradiance angle and incidence angle must be less than 45 to achieve good signal. Now transmitter FOV should be always above 50 to get maximum SNR. Using MIMO RC technique increase SNR of the system. VLC system support up to 10 Gbps system.

Override Magento 2 Class using Preference Method.

In Magento, sometimes we have to customize core function and classes. Whenever we have to override or rewrite class( Controller, Block & Model) Magento provides some methods.

1) Preference Method

2) Plugin Method

Override controller using Preference method. Preference overridden all function of the controller if some function is not listed in override controller execute from the original method.

For override some function you have to create a module. For module, creation check Click here.

After creating module Make di.xml file. In module make Panchal\Preference\etc/di.xml file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">    
    <preference for="Magento\Customer\Controller\Account\Create" type="Panchal\Preference\Controller\Account\Create" />
</config>

Now Make override controller in module Panchal\Preference\Controller\Account\Create.php
In controller, we override execute function you can override any function of this class.


<?php
namespace Panchal\Preference\Controller\Account;

class Create extends \Magento\Customer\Controller\Account\Create
{
    public function execute()
    {
		// Add your Logic here ( Restricat Some Country or IP)
		
        if ($this->session->isLoggedIn() || !$this->registration->isAllowed()) {
            /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
            $resultRedirect = $this->resultRedirectFactory->create();
            $resultRedirect->setPath('*/*');
            return $resultRedirect;
        }

        /** @var \Magento\Framework\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();
        return $resultPage;
    }
}

Base64 is Not Defined in Magento 2.3

In Magento 2.3 Admin Theme Configuration Tab is Continous Loading or Favicon or Logo File is Not Uploading.

How to Solve :
This Magento Bug is Overcome BY change Design.config.xml

Go to In Magento root Directory then vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml

Original Code :
Line 57

        <field name="head_shortcut_icon" formElement="fileUploader">
                <settings>
                    <notice translate="true">Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>fileUploader</componentType>
                </settings>

Line 154

<field name="header_logo_src" formElement="fileUploader">
                <settings>
                    <notice translate="true">Allowed file types: png, gif, jpg, jpeg.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>fileUploader</componentType>
                </settings>

Resolved Code :
line 57

        <field name="head_shortcut_icon" formElement="imageUploader">
                <settings>
                    <notice translate="true">Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>fileUploader</componentType>
                </settings>

Line 154

<field name="header_logo_src" formElement="imageUploader">
                <settings>
                    <notice translate="true">Allowed file types: png, gif, jpg, jpeg.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>fileUploader</componentType>
                </settings>

Replace New Code with old one, then Refresh cache.

Enjoy Your Development.
Pratik Panchal.

MAGENTO 2.3.0 Theme Configuration Issue

In Magento 2.3 Admin Theme Configuration Tab is Continous Loading or Favicon or Logo File is Not Uploading.

How to Solve :
This Magento Bug is Overcome BY change Design.config.xml

Go to In Magento root Directory then vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml

Original Code :
Line 57

        <field name="head_shortcut_icon" formElement="fileUploader">
                <settings>
                    <notice translate="true">Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>fileUploader</componentType>
                </settings>

Line 154

<field name="header_logo_src" formElement="fileUploader">
                <settings>
                    <notice translate="true">Allowed file types: png, gif, jpg, jpeg.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>fileUploader</componentType>
                </settings>

Resolved Code :
line 57

        <field name="head_shortcut_icon" formElement="imageUploader">
                <settings>
                    <notice translate="true">Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>fileUploader</componentType>
                </settings>

Line 154

<field name="header_logo_src" formElement="imageUploader">
                <settings>
                    <notice translate="true">Allowed file types: png, gif, jpg, jpeg.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>fileUploader</componentType>
                </settings>

Replace New Code with old one, then Refresh cache.

Enjoy Your Development.
Pratik Panchal.

Magento 2.3.0 Localhost (Frontend are Blank)

Frontend is Blank

All Template File is Not loading

After installing Magento 2.3 on localhost, some-time Magento all Template file is not loading, due to that Frontend id blank.

For debugging set developer mode in Magento. Then you got error Require-js.phtml is not defined or valid.

How to Solve it.

Open Magento\vendor\magento\framework\View\Element\Template\File\Validator.php File and edit Line no 138.
Old Code :

$realPath = $this->fileDriver->getRealPath($path);

New Code :

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

Replace New Code with old one, then Refresh cache.

Enjoy Your Development.
Pratik Panchal.

Create a Custom Magento Module

Magento Custom Module

Magento will provide all feature but sometimes we want to extend Magento basic function or class, make some content based extension (plug-In) or make some website(ex. e-bay, Amazon), application(ex. payment method, shipping method) integration for Magento 2.

How to make Custom Module ?, Which file is required?, Where to put in Magento root folder?

Magento is a bunch of many modules. specific features have own module in Magento like for product module name “module-catalog”. Custom Module Structure is same like Magento default module structure.
In custom module three file is required.
1) registration.php
2) etc/module.xml
3) composer.json (required if module want to install using SSH.)

Sample File of all Required Files.

registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'CodeWithGeek_Custom',
    __DIR__
);

Module.xml File is register module when deploy a magento. module.xml put in etc folder. “etc” folder located in Custom module root directory. In code is there, it means your module will be executed after tis module.

module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="CodeWithGeek_Custom" setup_version="1.0.0"></module>
        <sequence>
            <module name="Magento_Backend"/>
             <module name="Magento_Sales"/>
            <module name="Magento_Quote"/>
            <module name="Magento_Checkout"/>
        </sequence>
</config>

composer.json

{
    "name": "codewithgeek/custom",
    "description": "CodeWithGeek Custom",
    "require": {
      "php": "~5.6.0|7.0.2|~7.0.6",
      "magento/magento-composer-installer": "*"
    },
    "type": "magento2-module",
    "version": "0.74.0-beta4",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "extra": {
        "map": [
            [
                "*",
                "CodeWithGeek/Custom"
            ]
        ]
    }
}

MATLAB Code : SNR distribution for indoor VLC

Indoor VLC means Communication is possible in a small range that is useful in home, office and small area environments. Indoor VLC is next level of Home automation system. Whenever people think about Indoor VLC first question is why we use this and what is a feature?

1) Minimum Data Speed is 1 Gbps
2) No Signal Loss
3) Light is Not harmed the human body
4) Reusable Concept of Light
5) More Secure
Now Look like advantages are so many compare to current Wireless techniques but one disadvantage is this concept covers the only small area. Now How many Area’s are covered we see in next post currently we measure an important parameter of VLC SNR(Singal to Noise Ratio) for 1 V LED. Here MATLAB code is attached. Run in code in MATLAB and enjoy a graph of SNR.
For this Program assume 1 V LED is located in (0,0) point.

clear all;
clc;
close all;
% SNR Performance For VLC SYSTEM %
% Coded BY Er. PANCHAL PRATIK
% pattu310@gmail.com
% Easy USe Consider Following Example
%
%
% BASIC PARAMETER REQUIRED %
Incidence = 70*pi/180;
TX_FOV = 70; % Transmitter Field Of View
RX_FOV = 90; % Receivers Field Of View
Tx = [2,2,2]; % Transmitter Location
%Rxp = [2,2]; % Receiver Location
W_Room = 4; % Width of Room
L_Room = 4; % Length of Room
H_Room = 2; % Height Between Transmitter and Receiver
R = 1; % Responsivity of Photodiode
Apd = 1e-4; % Area of PhotoDetector
Rb = 1e6; % Data rate of system
Iamp = 5e-12; % Amplifier Current
q = 1.6e-19; % Electron Charge
Bn = 50e6; % Noise Bandwidth
I2 = 0.562; % Noise Bandwidth Factor
PLED = 1; % Power Emitted by LED
index =1;
HLED = 1;
[W L] = meshgrid(-(W_Room/2) : 0.50 : (W_Room/2)); % Consideer Length of BLock for Room
xydist = sqrt((W).^2 + (L).^2);
hdist = sqrt(xydist.^2 + HLED.^2);
%D = Tx – Rx;
%d = norm(D);
%Incidence = acos()
A_Irradiance = ((Tx(3)-HLED)./hdist);
%I(index) = Irradiance*180/pi;
%if abs(Incidence <= RX_FOV)
p = TX_FOV ;
Tx_FOV = (TX_FOV*pi)/180;
% BASIC CALCULATION IN VLC SYSTEM %
% Lambertian Pattern
m = real(-log(2)/log(cos(Tx_FOV)));
% Radiation Intensity at particular point
Ro = real(((m+1)/(2*pi)).*A_Irradiance^m);
% Transmitted power By LED
Ptx = PLED .* Ro;
% Channel Gain ( Channel Coefficient Of LOS Channel )
%Theta=atand(sqrt(sum((Tx-Rx).^2))/H_Room);
HLOS = (Apd./hdist.^2).*cos(Incidence).*Ro;
% Received Power By PhotoDetector
Prx = HLOS.*Ptx;
% Calculate Noise in System
Bs = Rb*I2;
Pn = Iamp/Rb;
Ptotal = Prx+Pn;
new_shot = 2*q*Ptotal*Bs;
new_amp = Iamp^2*Bn;
% Calculate SNR
new_total = new_shot + new_amp;
SNRl = (R.*Prx).^2./ new_total;
SNRdb = 10*log10(SNRl);
% else
% SNRl = 0;
% SNRdb = 0;
% end
index = index + 1;
% Plot Graph %
figure;
mesh(W,L,SNRdb);
%mesh(SNRdb);
%ylim([0 30]);
title(‘SNR Distribution in Room’);
xlabel(‘Length of Room’);
ylabel(‘Width of Room’);
zlabel(‘SNR in dB’);

Output : MATLAB graph
SNR of SISO VLC

Visible Light Communication (Part – 3)

VLC SYSTEM MODEL SISO

  • SISO: Single Input Single Output

In this section, we describe the Single Input Single Output VLC system and discuss the parameter of the VLC link. First, we consider the LOS link between the single transmitter and the receiver. The link configuration is shown in (fig1) [1].

SISO VLC SYSTEM MODEL

 

Where θ is the angle of incidence with respect to the axis of the receiver surface. Ҩ is receiver’s FOV. At transmitter side viewing angle (Irradiance) with respect to transmitter surface is Ø and transmitter FOV is ɸ. Lambertian emission defined as m [11].

Equation 1

Optical concentrator gain of the receiver [2] defined as.

Equation 2

VLC channel gain for LOS link determined by HLOS is,

Equation 2

Where 𝑅0(Ҩ) is [11],

𝑅0(Ҩ)=(𝑚+1)/(2∗𝜋)*𝑐𝑜𝑠2(∅) [4]

Where 𝐴𝑝𝑑 the collection area of the receiver is, 𝑑2is the distance from the transmitter to the receiver. θ is the angle of incidence on the receiver and Ҩ is the receiver’s FOV. For SISO system we have to consider only one LOS link so at receiver side only one channel gain calculated. A received signal is given by [2]

𝑅𝑥 = R∗𝑃𝑡∗HLOS + √σ2 [5]

Where R is the photodiode responsively. Pt is transmitted optical power and σ2 is the mean square noise current of a receiver. Transmitted power is defined as [11]

𝑃𝑡=𝑃𝐿𝐸𝐷∗𝑅0(Ҩ) [6]

Where PLED is, the power emitted by LED. Received data is recovered using the inverse of HLOS as [2]

𝑅𝑟𝑒𝑐𝑜𝑣𝑒𝑟𝑒𝑑=𝑅𝑥∗𝐻𝑇 [7]

Received power 𝑃𝑟 depends upon the filter transmission 𝑇𝑠(𝜃) and concentrator gain. Ideally, concentrator gain and transmission filter are considered as 1 [2].

𝑃𝑟= 𝑃𝑡∗𝐻𝐿𝑂𝑆∗g(𝜃)∗𝑇𝑠(𝜃), 0≤θ≤Ҩ [8]

SNR depend upon the photodetector responsivity R, received optical power and noise variance. SNR is [2]

SNR = (𝑅𝑃𝑡)2/𝜎𝑠ℎ𝑜𝑡2+𝜎𝑡ℎ𝑒𝑟𝑚𝑎𝑙2 [9]

Shot noise is photon generated noise in the detector by received signal and calculated as [1]

𝜎𝑠ℎ𝑜𝑡2=2𝑞𝑅𝑃𝑟𝐵 [10]

Thermal noise is given by [1],

𝜎𝑡ℎ𝑒𝑟𝑚𝑎𝑙2= 4𝐾𝑇𝐵𝐹𝑅𝑡 [11]

BER depends on the modulation scheme and SNR of the system. Where Q is a function that depends upon the modulation scheme which used.

BER = Q√𝑆𝑁𝑅 [12]